/*


MMMMMMMM               MMMMMMMM     OOOOOOOOO     NNNNNNNN        NNNNNNNNTTTTTTTTTTTTTTTTTTTTTTTHHHHHHHHH     HHHHHHHHH     [[[[[[[[[ZZZZZZZZZZZZZZZZZZZ]]]]]]]]]
M:::::::M             M:::::::M   OO:::::::::OO   N:::::::N       N::::::NT:::::::::::::::::::::TH:::::::H     H:::::::H     [:::::::[Z:::::::::::::::::Z]:::::::]
M::::::::M           M::::::::M OO:::::::::::::OO N::::::::N      N::::::NT:::::::::::::::::::::TH:::::::H     H:::::::H     [:::::::[Z:::::::::::::::::Z]:::::::]
M:::::::::M         M:::::::::MO:::::::OOO:::::::ON:::::::::N     N::::::NT:::::TT:::::::TT:::::THH::::::H     H::::::HH     [:::::[[[Z:::ZZZZZZZZ:::::Z ]]]:::::]
M::::::::::M       M::::::::::MO::::::O   O::::::ON::::::::::N    N::::::NTTTTTT  T:::::T  TTTTTT  H:::::H     H:::::H       [::::[   ZZZZZ     Z:::::Z     ]::::]
M:::::::::::M     M:::::::::::MO:::::O     O:::::ON:::::::::::N   N::::::N        T:::::T          H:::::H     H:::::H       [::::[           Z:::::Z       ]::::]
M:::::::M::::M   M::::M:::::::MO:::::O     O:::::ON:::::::N::::N  N::::::N        T:::::T          H::::::HHHHH::::::H       [::::[          Z:::::Z        ]::::]
M::::::M M::::M M::::M M::::::MO:::::O     O:::::ON::::::N N::::N N::::::N        T:::::T          H:::::::::::::::::H       [::::[         Z:::::Z         ]::::]
M::::::M  M::::M::::M  M::::::MO:::::O     O:::::ON::::::N  N::::N:::::::N        T:::::T          H:::::::::::::::::H       [::::[        Z:::::Z          ]::::]
M::::::M   M:::::::M   M::::::MO:::::O     O:::::ON::::::N   N:::::::::::N        T:::::T          H::::::HHHHH::::::H       [::::[       Z:::::Z           ]::::]
M::::::M    M:::::M    M::::::MO:::::O     O:::::ON::::::N    N::::::::::N        T:::::T          H:::::H     H:::::H       [::::[      Z:::::Z            ]::::]
M::::::M     MMMMM     M::::::MO::::::O   O::::::ON::::::N     N:::::::::N        T:::::T          H:::::H     H:::::H       [::::[   ZZZ:::::Z     ZZZZZ   ]::::]
M::::::M               M::::::MO:::::::OOO:::::::ON::::::N      N::::::::N      TT:::::::TT      HH::::::H     H::::::HH     [:::::[[[Z::::::ZZZZZZZZ:::Z]]]:::::]
M::::::M               M::::::M OO:::::::::::::OO N::::::N       N:::::::N      T:::::::::T      H:::::::H     H:::::::H     [:::::::[Z:::::::::::::::::Z]:::::::]
M::::::M               M::::::M   OO:::::::::OO   N::::::N        N::::::N      T:::::::::T      H:::::::H     H:::::::H     [:::::::[Z:::::::::::::::::Z]:::::::]
MMMMMMMM               MMMMMMMM     OOOOOOOOO     NNNNNNNN         NNNNNNN      TTTTTTTTTTT      HHHHHHHHH     HHHHHHHHH     [[[[[[[[[ZZZZZZZZZZZZZZZZZZZ]]]]]]]]]
Project Survival

  __  __ _   ___  __    _  _  ____  ____
 (  )(  ( \ / __)(  )  / )( \(    \(  __)
  )( /    /( (__ / (_/\) \/ ( ) D ( ) _)
 (__)\_)__) \___)\____/\____/(____/(____)
*/

#include <a_samp>
#include <rnpc>
#include <simpleINI>
#include <sscanf2>
#include <streamer>
#include <playerprogress>
#include <zcmd>
#include <mSelection>
#include <YSI\y_timers>
#include <newsamp>
#include <expo>

#define CBUG_INTERVAL_DEAGLE	700
#define CBUG_INTERVAL_SHOTGUN	1000
#define CBUG_INTERVAL_COMBATSG	340
#define CBUG_INTERVAL_COUNTRY	850
#define CBUG_INTERVAL_SNIPER 	850

/*
 ____  ____  ____  __  __ _  ____
(    \(  __)(  __)(  )(  ( \(  __)
 ) D ( ) _)  ) _)  )( /    / ) _)
(____/(____)(__)  (__)\_)__)(____)
*/
//dialog
#define DIALOG_LOGIN 			0
#define DIALOG_REGISTER 		1
#define DIALOG_LANGUAGE 		2
#define DIALOG_EDITBD 			3
#define DIALOG_GATE 			4
#define Dialog_GetRangeBuild 	5
#define Dialog_SetupPass 		6
#define Dialog_EnterPass 		7
#define Dialog_Craft            8
//TEAM
#define TEAM_SUR 1//GREEN
#define TEAM_2 	 2 //red
#define TEAM_3 	 3 //yellow
#define TEAM_4 	 4 //light blue
#define COLOR_TEAM1 0x33AA33AA
#define COLOR_TEAM2 0xAA3333AA
#define COLOR_TEAM3 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_TEAM4 0x33CCFFAA
#define COLOR_RED			0xFF000000
#define COLOR_YELLOW 		0xFFFF0000
#define COLOR_GREEN 		0x00FF0000
//
#define FUEL_DECREASE 1
#define Z_WHITE "{FFFFFF}"
#define Z_ORANGE "{DB881A}"
#define MAX_ZOMBIES 29
#define MAXZRANGE 50
#define MAX_Build 2000
////MAX AMOUNT DROP ITEM
#define MAX_DROP_ITEMS 10000
#define MAX_LOOTS_SPAWN 10000
//tree
#define MAX_TREES 1000
/// M selection Menu extra id
#define INVENTORY_MENU 1
#define BOX_MENU 2
#define PUTBOX_MENU 3
#define CARBOX_MENU 4
#define BOXCAR_MENU 5
#define PUTCARBOX_MENU 6
///Dialog id
#define DIALOG_INV 213
#define DIALOG_BOX 214
///MAX SLOT
#define MAX_SLOT 50
///vehicle
#undef MAX_VEHICLES
	#define MAX_VEHICLES 100
#define PRESSED(%0) \
        (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
//
#define MPH_KMH 1.609344
/*
Type 1: food and drink
Type 2: Tool Vehicle
Type 3: Ammo
Type 4 Hospital
Type 5 Skin
Type 6 Bag
Type 7 Weapon
Type 8 Building
*/
//=====================Type 1 Food and Drink
//food
#define I_Pizza 1582// amount 1 = cook , amount 0 = uncook
#define I_Burger 2703// amount 1 = cook , amount 0 = uncook
#define I_Taco 2769// amount 1 = cook , amount 0 = uncook
#define I_Hotdog 19346// amount 1 = cook , amount 0 = uncook
//Drink
#define I_SodaCan 2601
#define I_Bottle 1950 // amount 1 = water bottle amount 0 = empty water bottle
#define I_NuocCam 1546
#define I_Pesi 2647
//=====================Type 2 Tool // vehicle
#define I_Lighter 327
#define I_Ladder 1428
#define I_Hammer 18635
#define I_Keypad 2922
#define I_GasCan 1650 // amount 1 = full . amount 0 == empty
#define I_Wood 1463
#define I_Wheel 1085
#define I_Tankpart 1010
#define I_Engine 920
#define I_ToolBox 2969
#define ITEMBOX 2384
//=====================Type 3 Ammo
#define I_AmmoSlot2 2039
#define I_AmmoSlot3 2038
#define I_AmmoSlot4 2037
#define I_AmmoSlot5 2040
#define I_AmmoSlot6 3052
#define I_AmmoSlot7 3016
//=====================Type 4 Skin / Hospital
#define I_Cloth 2386
#define I_Bandage 1666
#define I_Medkit 1580
#define I_Pills 2709
#define I_AntiVirus 1933
//
#define I_Gate 19303
#define I_Metal 16637
#define I_Bag 3026
#define I_VatLieu 1279
///////////////////////////////////////////
#define TEXTURE_1	2068,	"cj_ammo_net",		"CJ_cammonet"
#define TEXTURE_2	693,	"gta_tree_pine",	"sm_redwood_branch"
#define TEXTURE_3	693,	"gta_tree_pine",	"sm_pinetreebit"

#define DEFAULT		TEXTURE_2
/*
 __ _  ____  _  _
(  ( \(  __)/ )( \
/    / ) _) \ /\ /
\_)__)(____)(_/\_)
*/
new Text:FuelText[MAX_PLAYERS];
new FuelTimer[MAX_PLAYERS];
new Text:TextConnect[8];
new PlayerText:Textdraw0;
new PlayerText:Textdraw1;
new PlayerText:Textdraw2;
new PlayerText:Textdraw3;
new PlayerText:Textdraw4;
new PlayerText:Textdraw5;
new PlayerText:Textdraw6;
new PlayerText:Textdraw7;
new PlayerText:Textdraw8;
new PlayerText:Textdraw9;
new PlayerText:Textdraw10;
new PlayerText:Textdraw11;
new PlayerText:Textdraw12;
new PlayerText:Textdraw13;
new PlayerText:Textdraw14;
new PlayerText:Textdraw15;
new PlayerText:Textdraw16;
new PlayerText:Textdraw17;
new PlayerText:Textdraw18;
new PlayerText:Textdraw19;
new PlayerText:Textdraw20;
new PlayerText:Textdraw21;
new PlayerText:Textdraw22;
new PlayerText:Textdraw23;

new PlayerText:TextVehicle0;
new PlayerText:TextVehicle1;
new PlayerText:TextVehicle2;
new PlayerText:TextVehicle3;
new PlayerText:TextVehicle4;
new PlayerText:TextVehicle5;
new PlayerText:TextVehicle6;

new PlayerText:ZombieRange;
new PlayerBar:HungerBar;
new PlayerBar:ThirstBar;
new PlayerBar:ExpBar;
new PlayerBar:TempBar;
new PlayerBar:ZombieHP[MAX_PLAYERS];
new PlayerBar:HealthBar[MAX_PLAYERS];
new PlayerBar:FuelBar;
new ZHPT[MAX_PLAYERS];
new FPSSMONE = 0;
//ITEM TYPE
new ItemType1[8] =
{
I_Pizza,I_Burger,I_Taco,I_Hotdog,I_SodaCan,I_Bottle,I_NuocCam,I_Pesi
};
new ItemType2[9] =
{
I_GasCan,I_Wood,ITEMBOX,I_Wheel,I_Tankpart,I_Engine,I_ToolBox,I_Hammer,I_Lighter
};
new ItemType3[6] =
{
I_AmmoSlot2,I_AmmoSlot3,I_AmmoSlot4,I_AmmoSlot5,I_AmmoSlot6,I_AmmoSlot7
};
new ItemType4[4]=
{
I_Bandage,I_Medkit,I_Pills,I_AntiVirus
};
new ItemType8[2]=
{
I_Metal,I_Gate
};
//MAX BOX
#define MAX_BOXS 1000
//////////////////////
#define 		LIGHTRED 						0xFF8080FF
///////////////////
new PlayerText:TextPutW;
new PlayerText:TextPutInvWN;
native IsValidVehicle(vehicleid);
enum // Tires
{
	CAR_BANHTRUOC_TRAI,
	CAR_BANHSAU_TRAI,
	CAR_BANHTRUOC_PHAI,
	CAR_BANHSAU_PHAI,
	BIKE_BANHTRUOC,
	BIKE_BANHSAU
}
enum //attach slot
{
	SLOT_HAT,//0
	SLOT_MASK,//1
	SLOT_TOY1,//2
	SLOT_TOY2,//3
	SLOT_TOY3,//4
	SLOT_TOY4,//5
	//
	SLOT_WEAPON2,//6
	SLOT_WEAPON6,//7
	SLOT_BLEED,//8
	SLOT_BAG//9
}
#define MAX_CFS 1000
enum cf
{
	cCreate,
	cObject1,
	cObject2,
	Float:cPosX,
	Float:cPosY,
	Float:cPosZ
}
new CampFire[MAX_CFS][cf];

enum bInfo
{
	bCreate,
	bObject,
	Float:bPosX,
	Float:bPosY,
	Float:bPosZ,
	bItem[21],
	bAmount[21]
};
new BoxInfo[MAX_BOXS][bInfo];
enum linfo
{
	lCreate,
	lType,
	Float:lPosX,
	Float:lPosY,
	Float:lPosZ,
}
new LootInfo[MAX_LOOTS_SPAWN][linfo];
enum tinfo
{
	tCreate,
	tObject,
	Float:tHealth,
	Float:tPosX,
	Float:tPosY,
	Float:tPosZ,
}
new TreeInfo[MAX_TREES][tinfo];
enum inv
{
	iSlot[50],
	iAmount[50]
}
new InvInfo[MAX_PLAYERS][inv];
new ItemObject[MAX_DROP_ITEMS];
new	Text3D:LabelItem[MAX_DROP_ITEMS];
enum bdInfo
{
	bdID,
	bdPass,
	bdObject,
	bdLock,
	bdModel,
	Float:bdX,
	Float:bdY,
	Float:bdZ,
	Float:bdRX,
	Float:bdRY,
	Float:bdRZ,
	bdvID,
	bdInt,
}
new BuildInfo[MAX_Build][bdInfo];

new PlayerUseingBuild[MAX_PLAYERS];

new ShowPlayerRangeBuild[MAX_PLAYERS][MAX_Build];
//
new bool:swimming[MAX_PLAYERS];
forward IsPlayerInWater(playerid);

public IsPlayerInWater(playerid)
{
    if(swimming[playerid]) return 1;
    return 0;
}
//ANTI CBUG

// Used for getting shot intervals
new lastDShot[MAX_PLAYERS];

// If 1, extra cbug shots are unsynced automatically
new removeCBugs = 1;
// If 1, OnPlayerCBug is called on cbug usages
new alertCBugs = 1;
// Callback forward
forward OnPlayerCBug(playerid, weaponid, interval);
forward SaveBuild(idx);
forward LoadBuild();
forward CreateBuild(ID);
//
//
/*
	Tire Car TireBike
	1-3         1
	| |         |
	2-4         2
*/
enum vh
{
	vModel,
	vEngine,
	Float:vHealth,
	Float:vFuel,
	Float:vPosX,
	Float:vPosY,
	Float:vPosZ,
	vTankpart,
	vCTire1,
	vCTire2,
	vCTire3,
	vCTire4,
}
new CarData[MAX_VEHICLES][vh];
new CarEngine[MAX_VEHICLES]; //0 == off , 1 == on
//=================
enum ItemData
{
    ItemModel,
    ItemAmount,
    Float:ItemPosX,
    Float:ItemPosY,
    Float:ItemPosZ,
    Float:ItemRotX,
    Float:ItemRotY,
    Float:ItemRotZ,
    ItemVWorld,
    ItemInterior,
};
new ItemInfo[MAX_DROP_ITEMS][ItemData];
//gate

/*enum ZD
{
	NM,
	Bommer,
	Boss,
	Chainsaw, // VERSION 3
	Katana,
}
new ZombieData[MAX_ZOMBIES][ZD];*/
new RedRadar;
main()
{
	print("\n----------------------------------");
	print("          PROJECT SURVIVAL          ");
	print("             MONTH  [Z]          ");
	print("----------------------------------\n");
}
enum pinfo
{
	Password,
	Admin,
	Money,
	RTeam,
	EXP,
 	NEXP,
	Level,
	Language,
	MSlot,
	Slotu,
	Kill,
	HShoot,
Float:px,
Float:py,
Float:pz,
	VW,
	Int,
Float:Blood,
Float:MaxBlood,
Float:Hunger,
Float:Thirst,
Float:Temp,
	IsSpawn,
	Mission,
	Bleed,
	Broken,
	Virus,
	ZKill,
	Skin,
	Weapon1,
	Weapon2,
	Weapon3,
	Weapon4,
	Weapon5,
	Weapon6,
	Weapon7,
	Weapon8,
	Weapon9,
	Weapon10,
	Weapon11,
	Weapon12,
	Ammo1,
	Ammo2,
	Ammo3,
	Ammo4,
	Ammo5,
	Ammo6,
	Ammo7,
	Ammo8,
	Ammo9,
	Ammo10,
	Ammo11,
	Ammo12,

}//team 1 = zombie , 2 = human , 0 = npc| language 1= English 2= VietNamese
new PlayerInfo[MAX_PLAYERS][pinfo];
enum
{
	CAMERA_MODE_STAND,
	CAMERA_MODE_CROUCH,
	CAMERA_MODE_CROUCH_MOVE
}


new
		fps_ObjectID[MAX_PLAYERS],
		fps_Active[MAX_PLAYERS],
		fps_Timer[MAX_PLAYERS],
		fps_CameraMode[MAX_PLAYERS];


new Float:RandomZSpawns[][] =
{
{1173.3685,1346.7798,10.9219,13.0367},
{1165.7307,1353.6250,10.9219,72.5707},
{1166.0168,1332.1368,10.8125,175.6349},
{1143.8441,1337.5414,10.8203,52.1804},
{1400.7328,1104.1094,10.8203,294.9993},
{1424.3738,1093.9014,10.8203,230.5880},
{1667.9362,898.3077,10.7734,217.1212},
{1646.6959,892.4413,10.7247,90.8529},
{115.4893,1759.9348,17.6406,242.6663}, // zombiespawnmap1
{111.9337,1737.0372,18.3479,183.4457}, // zombiespawnmap1
{113.3124,1714.1389,17.6406,183.4457}, // zombiespawnmap1
{117.0208,1690.0474,17.6406,192.8830}, // zombiespawnmap1
{114.5291,1671.6664,17.5153,170.9122}, // zombiespawnmap1
{125.1376,1655.0892,17.0418,238.5928}, // zombiespawnmap1
{157.2134,1646.5586,17.2266,268.0464}, // zombiespawnmap1
{187.6400,1646.6484,17.2266,268.0465}, // zombiespawnmap1
{224.1698,1645.4025,17.8378,268.0465}, // zombiespawnmap1
{246.9939,1646.6924,17.8258,273.9999}, // zombiespawnmap1
{267.2619,1648.1097,17.8851,273.9999}, // zombiespawnmap1
{298.8371,1654.2888,18.9388,302.2001}, // zombiespawnmap1
{318.8781,1676.5496,18.2180,349.5139}, // zombiespawnmap1
{318.1017,1708.9022,17.3238,2.3607}, // zombiespawnmap1
{316.9621,1736.5490,17.5780,2.3607}, // zombiespawnmap1
{306.4355,1774.7213,17.6406,22.1009}, // zombiespawnmap1
{288.6110,1786.4368,17.6406,93.2282}, // zombiespawnmap1
{-114.9950,1084.0469,19.7226,190.2985}, // zombienpcmap2
{-66.2824,1077.8777,19.5938,220.5717}, // zombienpcmap2
{-31.8212,1030.2791,19.7422,214.4980} // zombienpcmap2
};
//


SaveDatabase(playerid)
{

	new string[128];format(string,sizeof(string),"Warz/User/%s.dt",GetName(playerid));
	new Float:x,Float:y,Float:z;//,Ammo;
	GetPlayerPos(playerid,x,y,z);
    if(!fexist(string))
    {
    file_Create(string);
    }
    file_Open(string);
    //save
    file_SetVal("Admin",PlayerInfo[playerid][Admin]);
    file_SetVal("Money",PlayerInfo[playerid][Money]);
    file_SetVal("RTeam",PlayerInfo[playerid][RTeam]);
    file_SetVal("EXP",PlayerInfo[playerid][EXP]);
    file_SetVal("NEXP",PlayerInfo[playerid][NEXP]);
    file_SetVal("Level",PlayerInfo[playerid][Level]);
    file_SetVal("Language",PlayerInfo[playerid][Language]);
    file_SetVal("MSlot",PlayerInfo[playerid][MSlot]);
    file_SetVal("Slotu",PlayerInfo[playerid][Slotu]);
    file_SetVal("Kill",PlayerInfo[playerid][Kill]);
    file_SetVal("HShoot",PlayerInfo[playerid][HShoot]);
    file_SetVal("IsSpawn",PlayerInfo[playerid][IsSpawn]);
    file_SetVal("ZKill",PlayerInfo[playerid][ZKill]);
    file_SetVal("Skin",PlayerInfo[playerid][Skin]);
    file_SetVal("Weapon1",PlayerInfo[playerid][Weapon1]);
    file_SetVal("Weapon2",PlayerInfo[playerid][Weapon2]);
    file_SetVal("Weapon3",PlayerInfo[playerid][Weapon3]);
    file_SetVal("Weapon4",PlayerInfo[playerid][Weapon4]);
    file_SetVal("Weapon5",PlayerInfo[playerid][Weapon5]);
    file_SetVal("Weapon6",PlayerInfo[playerid][Weapon6]);
    file_SetVal("Weapon7",PlayerInfo[playerid][Weapon7]);
    file_SetVal("Weapon8",PlayerInfo[playerid][Weapon8]);
    file_SetVal("Weapon9",PlayerInfo[playerid][Weapon9]);
    file_SetVal("Weapon10",PlayerInfo[playerid][Weapon10]);
    file_SetVal("Weapon11",PlayerInfo[playerid][Weapon11]);
    file_SetVal("Weapon12",PlayerInfo[playerid][Weapon12]);
    file_SetVal("Ammo2",PlayerInfo[playerid][Ammo2]);
    file_SetVal("Ammo3",PlayerInfo[playerid][Ammo3]);
    file_SetVal("Ammo4",PlayerInfo[playerid][Ammo4]);
    file_SetVal("Ammo5",PlayerInfo[playerid][Ammo5]);
    file_SetVal("Ammo6",PlayerInfo[playerid][Ammo6]);
    file_SetVal("Ammo7",PlayerInfo[playerid][Ammo7]);
    file_SetVal("Ammo8",PlayerInfo[playerid][Ammo8]);
    file_SetVal("Ammo9",PlayerInfo[playerid][Ammo9]);
    file_SetVal("Ammo10",PlayerInfo[playerid][Ammo10]);
    file_SetVal("Ammo11",PlayerInfo[playerid][Ammo11]);
    file_SetVal("Ammo12",PlayerInfo[playerid][Ammo12]);
    file_SetVal("Mission",PlayerInfo[playerid][Mission]);
    file_SetVal("Bleed",PlayerInfo[playerid][Bleed]);
    file_SetVal("Broken",PlayerInfo[playerid][Broken]);
    file_SetVal("Virus",PlayerInfo[playerid][Virus]);
    file_SetVal("VW",GetPlayerVirtualWorld(playerid));
    file_SetVal("Int",GetPlayerInterior(playerid));
	//float
	file_SetFloat("x",x);
	file_SetFloat("y",y);
	file_SetFloat("z",z);
	file_SetFloat("Blood",PlayerInfo[playerid][Blood]);
	file_SetFloat("MaxBlood",PlayerInfo[playerid][MaxBlood]);
	file_SetFloat("Hunger",PlayerInfo[playerid][Hunger]);
	file_SetFloat("Thirst",PlayerInfo[playerid][Thirst]);
	file_SetFloat("Temp",PlayerInfo[playerid][Temp]);
    //======
    file_Save(string);
    file_Close();
	SaveInventory(playerid);
	return 1;
}
LoadDatabase(playerid)
{
	new string[128];format(string,sizeof(string),"Warz/User/%s.dt",GetName(playerid));
	if(!fexist(string)) return 1;
	file_Open(string);
	PlayerInfo[playerid][Admin] = file_GetVal("Admin");
	PlayerInfo[playerid][Money] = file_GetVal("Money");
	PlayerInfo[playerid][RTeam] = file_GetVal("RTeam");
	PlayerInfo[playerid][EXP] = file_GetVal("EXP");
	PlayerInfo[playerid][NEXP] = file_GetVal("NEXP");
	PlayerInfo[playerid][Level] = file_GetVal("Level");
	PlayerInfo[playerid][Language] = file_GetVal("Language");
	PlayerInfo[playerid][MSlot] = file_GetVal("MSlot");
	PlayerInfo[playerid][Slotu] = file_GetVal("Slotu");
	PlayerInfo[playerid][Kill] = file_GetVal("Kill");
	PlayerInfo[playerid][HShoot] = file_GetVal("HShoot");
	PlayerInfo[playerid][IsSpawn] = file_GetVal("IsSpawn");
	PlayerInfo[playerid][ZKill] = file_GetVal("ZKill");
	PlayerInfo[playerid][Skin] = file_GetVal("Skin");
	PlayerInfo[playerid][Weapon1] = file_GetVal("Weapon1");
	PlayerInfo[playerid][Weapon2] = file_GetVal("Weapon2");
	PlayerInfo[playerid][Weapon3] = file_GetVal("Weapon3");
	PlayerInfo[playerid][Weapon4] = file_GetVal("Weapon4");
	PlayerInfo[playerid][Weapon5] = file_GetVal("Weapon5");
	PlayerInfo[playerid][Weapon6] = file_GetVal("Weapon6");
	PlayerInfo[playerid][Weapon7] = file_GetVal("Weapon7");
	PlayerInfo[playerid][Weapon8] = file_GetVal("Weapon8");
	PlayerInfo[playerid][Weapon9] = file_GetVal("Weapon9");
	PlayerInfo[playerid][Weapon10] = file_GetVal("Weapon10");
	PlayerInfo[playerid][Weapon11] = file_GetVal("Weapon11");
	PlayerInfo[playerid][Weapon12] = file_GetVal("Weapon12");
	PlayerInfo[playerid][Ammo2] = file_GetVal("Ammo2");
	PlayerInfo[playerid][Ammo3] = file_GetVal("Ammo3");
	PlayerInfo[playerid][Ammo4] = file_GetVal("Ammo4");
	PlayerInfo[playerid][Ammo5] = file_GetVal("Ammo5");
	PlayerInfo[playerid][Ammo6] = file_GetVal("Ammo6");
	PlayerInfo[playerid][Ammo7] = file_GetVal("Ammo7");
	PlayerInfo[playerid][Ammo8] = file_GetVal("Ammo8");
	PlayerInfo[playerid][Ammo9] = file_GetVal("Ammo9");
	PlayerInfo[playerid][Ammo10] = file_GetVal("Ammo10");
	PlayerInfo[playerid][Ammo11] = file_GetVal("Ammo11");
	PlayerInfo[playerid][Ammo12] = file_GetVal("Ammo12");
	PlayerInfo[playerid][Mission] = file_GetVal("Mission");
	PlayerInfo[playerid][Bleed] = file_GetVal("Bleed");
	PlayerInfo[playerid][Broken] = file_GetVal("Broken");
	PlayerInfo[playerid][Virus] = file_GetVal("Virus");
	PlayerInfo[playerid][VW] = file_GetVal("VW");
	PlayerInfo[playerid][Int] = file_GetVal("Int");
	
	PlayerInfo[playerid][px] = file_GetFloat("x");
	PlayerInfo[playerid][py] = file_GetFloat("y");
	PlayerInfo[playerid][pz] = file_GetFloat("z");
	PlayerInfo[playerid][Blood] = file_GetFloat("Blood");
	PlayerInfo[playerid][MaxBlood] = file_GetFloat("MaxBlood");
	PlayerInfo[playerid][Hunger] = file_GetFloat("Hunger");
	PlayerInfo[playerid][Thirst] = file_GetFloat("Thirst");
	PlayerInfo[playerid][Temp] = file_GetFloat("Temp");
	file_Save(string);
    file_Close();
	LoadInventory(playerid);
//	SetPlayerHealth(playerid,100);
	return 1;
}

public OnGameModeInit()
{
	SetGameModeText("Month[Z]-(v0.1)");
	SetWeather(42);
	//AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	RedRadar= GangZoneCreate(-3334.758544, -3039.903808, 3049.241455, 3184.096191);
	LoadVehicles();
	MapAndreas_Init(MAP_ANDREAS_MODE_NOBUFFER);
	ConnectRNPC("ZOMBIE");
	ShowPlayerMarkers(PLAYER_MARKERS_MODE_OFF);
	repeat UpdateZombieMovement();
	repeat UpdateZombiePunch();
	repeat RespawnZombieDie();
	repeat AntiCheatTimer();
	repeat ReSpawnTrees();
	LoadBoxs();
	LoadPointLoot();
	LoadTrees();
 	LoadBuild();
	TextInit();
	
	MapInit();
	ConnectRNPC("ZOMBIE");
	SetTimerEx("ConnectZombieBots",5000,0,"i",MAX_ZOMBIES);
	
	return 1;
}

public OnGameModeExit()
{
	for(new i=1; i<MAX_Build; i++)
	{
	    if(BuildInfo[i][bdID] != 0)
	    {
			DestroyDynamicObject(BuildInfo[i][bdObject]);
			BuildInfo[i][bdID] = 0;
	    }
	}
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid,"Mine",0);
    SetPlayerWeather(playerid, 42);
	if(IsPlayerNPC(playerid)) return 1;
	for(new i =0; i < 8; i ++)
	{
		TextDrawShowForPlayer(playerid,TextConnect[i]);
	}
	LoadPText(playerid);
	FuelBar = CreatePlayerProgressBar(playerid,555.00, 429.00, 79.50, 9.19,0x33AA33AA, 100.0);
    ZombieHP[playerid] = CreatePlayerProgressBar(playerid,31.00, 442.00, 54.50, 2.50, -16776961, 100.0);
    HealthBar[playerid] = CreatePlayerProgressBar(playerid,549.00, 69.00, 56.50, 3.20,0x33AA33AA, 100.0);
    HungerBar =	CreatePlayerProgressBar(playerid,513.00, 109.00, 91.50, 4.19, 0x33AA33AA, 100.0);
	ThirstBar = CreatePlayerProgressBar(playerid,513.00, 120.00, 91.50, 3.20, 0x33AA33AA, 100.0);
	ExpBar = CreatePlayerProgressBar(playerid,513.00, 139.00, 91.50, 2.50, 0x33AA33AA, 100.0);
	TempBar = CreatePlayerProgressBar(playerid,513.00, 129.00, 91.50, 4.19, 0x33AA33AA,100.0);
	new string[128];format(string,sizeof(string),"Warz/User/%s.dt",GetName(playerid));
	if(fexist(string))
	{
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"LOGIN","WELLCOME BACK Month [Z]","Login","Quit");
	}
	else
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"REGISTER","WELLCOME TO Month [Z]","Register","Quit");
	}
	return 1;
}
public OnRNPCDeath(npcid, killerid, reason)
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(npcid,x,y,z);
	if(GetPlayerSkin(npcid) == 264)
	{
	CreateExplosionEx(npcid, x,y,z,10,random(60),EXPLOSION_TYPE_MOLOTOV,51,true);
	}
	
    if(GetPVarInt(npcid,"HS") == 1)
    {
    	PlayAnim(npcid, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
    }
    else
    {
    	PlayAnim(npcid, "PED", "KO_shot_stom", 4.0, 0, 1, 1, 1, 0, 1);
    }
    if(killerid != INVALID_PLAYER_ID)
    {
        PlayerInfo[killerid][ZKill] += 1;
        PlayerInfo[killerid][EXP] += 1;
        PlayerInfo[killerid][Money] += 10;
        CheckUpdateLevel(killerid);
    }
    SetPVarInt(npcid,"HS",0);
	return 1;
}
timer RespawnZombieDie[60000]()
{
	for(new npcid = 0 ; npcid < MAX_ZOMBIES;npcid++)
	{
	    if(IsPlayerNPC(npcid))
	    {
			if(GetRNPCHealth(npcid) <= 0.0)
			{
		    RespawnRNPC(npcid);
		    }
	    }
    }
	return 1;
}
timer AntiCheatTimer[1000]()
{
//	new PlayerWeapon;
    new Float:HP,Float:ar;
	foreach(Player, i)
    {
        if(GetPVarInt(i,"StartCheck") == 1)
        {
			GetPlayerHealth(i,HP);
			GetPlayerArmour(i,ar);
			if(HP> PlayerInfo[i][Blood])
			{
				SetPlayerHP(i,PlayerInfo[i][Blood]);
			}
			else if(HP< PlayerInfo[i][Blood])
			{
				SetPlayerHP(i,HP);
			}
			if(ar > 1)
			{
				new string[128];format(string,sizeof(string),"[Hack/Cheat] %s has been kick by Server : reason Armour Hack",GetName(i));
				SendClientMessageToAll(COLOR_TEAM2,string);
	  			Kick(i);
			}
			if(GetPlayerSkin(i) != PlayerInfo[i][Skin])
			{
	  			SetPlayerSkinEx(i,PlayerInfo[i][Skin]);
			}
			PlayerInfo[i][Hunger] -= 0.0138;
			PlayerInfo[i][Thirst] -= 0.0277;
			if(PlayerInfo[i][Hunger] <= 0 || PlayerInfo[i][Thirst] <= 0 || PlayerInfo[i][Temp] <= 0)
			{
			    SetPlayerHP(i,0.0);
			}
			if(PlayerInfo[i][Temp] > 100.0)
			{
				PlayerInfo[i][Temp] = 100.0;
			}
			if(PlayerInfo[i][Hunger] > 100.0)
			{
				PlayerInfo[i][Hunger] = 100.0;
			}
			if(PlayerInfo[i][Thirst] > 100.0)
			{
			    PlayerInfo[i][Thirst] = 100.0;
			}
			if(IsPlayerInWater(i))
			{
			PlayerInfo[i][Temp] -= 0.07;
			}
			else
			{
			PlayerInfo[i][Temp] -= 0.02;
			}
			if(PlayerInfo[i][Bleed] == 1)
			{
			new Float:hhp;GetPlayerHealth(i,hhp);
			SetPlayerAttachedObject(i,SLOT_BLEED, 18706, 1,  0.088999, 0.020000, 0.044999,  0.088999, 0.020000, 0.044999,  1.179000, 1.510999, 0.005000);
			SetPlayerHealth(i,hhp-0.01);
			}
			else if(PlayerInfo[i][Bleed] == 0)
			{
			RemovePlayerAttachedObject(i,SLOT_BLEED);
			}
			if(PlayerInfo[i][Virus] == 1)
			{
			new Float:hhp;GetPlayerHealth(i,hhp);
			SetPlayerDrunkLevel(i,GetPlayerDrunkLevel(i)+500);
			SetPlayerHealth(i,hhp-0.001);
			}
			ShowBarHP(i);
			StatsText(i);
			ShowBarStats(i);
			for(new ic = 0 ; ic < MAX_CFS;ic++)
			{
				if(IsPlayerInRangeOfPoint(i,3,CampFire[ic][cPosX],CampFire[ic][cPosY],CampFire[ic][cPosZ]))
				{
				PlayerInfo[i][Temp] += 0.3;
				}
			}
	  		new weaponid = GetPlayerWeapon(i);
	  		new ammo = GetPlayerAmmo(i);
		    new weapon1 = PlayerInfo[i][Weapon1],
		    weapon2 =PlayerInfo[i][Weapon2],
		    weapon3 =PlayerInfo[i][Weapon3],
		    weapon4 =PlayerInfo[i][Weapon4],
		    weapon5 =PlayerInfo[i][Weapon5],
		    weapon6 =PlayerInfo[i][Weapon6],
		    weapon7 =PlayerInfo[i][Weapon7],
		    weapon8 =PlayerInfo[i][Weapon8],
		    weapon9 =PlayerInfo[i][Weapon9],
		    weapon10 =PlayerInfo[i][Weapon10],
		    weapon11 =PlayerInfo[i][Weapon11],
		    weapon12 =PlayerInfo[i][Weapon12];
//		    new string[128];
		    switch(weaponid)
		    {
			    case 2..46:
			    {
				    if(weapon1 != weaponid&&weapon2 != weaponid&&weapon3 != weaponid&&weapon4 != weaponid&&weapon5 != weaponid&&weapon6 != weaponid&&weapon7 != weaponid&&weapon8!= weaponid&&weapon9 != weaponid&&weapon10 != weaponid&&weapon11 != weaponid&&weapon12 != weaponid)
				    {
				    RemovePlayerWeapon(i, weaponid);
				    }
			    }
		    }
	    	switch(weaponid)
	    	{
			    case 2..9:
			    {

					if(PlayerInfo[i][Ammo1] > ammo)
				    {
				        PlayerInfo[i][Ammo1] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo1] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon1],PlayerInfo[i][Ammo1]);
				    }
			    }
			    case 10..15:
			    {
			    	if(PlayerInfo[i][Ammo10] > ammo)
				    {
				        PlayerInfo[i][Ammo10] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo10] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon10],PlayerInfo[i][Ammo10]);
				    }
			    }
			    case 16..18:
			    {
		     		if(PlayerInfo[i][Ammo8] > ammo)
				    {
				        PlayerInfo[i][Ammo8] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo8] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon8],PlayerInfo[i][Ammo8]);
				    }
			    }
			    case 22..24:
			    {
			    	if(PlayerInfo[i][Ammo2] > ammo)
				    {
				        PlayerInfo[i][Ammo2] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo2] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon2],PlayerInfo[i][Ammo2]);
				    }
			    }
			    case 25..27:
			    {
			    	if(PlayerInfo[i][Ammo3] > ammo)
				    {
				        PlayerInfo[i][Ammo3] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo3] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon3],PlayerInfo[i][Ammo3]);
				    }
			    }
			    case 28..29:
			    {
			    	if(PlayerInfo[i][Ammo4] > ammo)
				    {
				        PlayerInfo[i][Ammo4] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo4] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon4],PlayerInfo[i][Ammo4]);
				    }
			    }
			    case 30..31:
			    {
			    	if(PlayerInfo[i][Ammo5] > ammo)
				    {
				        PlayerInfo[i][Ammo5] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo5] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon5],PlayerInfo[i][Ammo5]);
				    }
			    }
			    case 32:
			    {
			    	if(PlayerInfo[i][Ammo4] > ammo)
				    {
				        PlayerInfo[i][Ammo4] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo4] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon4],PlayerInfo[i][Ammo4]);
				    }
			    }
			    case 33..34:
			    {
			    	if(PlayerInfo[i][Ammo6] > ammo)
				    {
				        PlayerInfo[i][Ammo6] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo6] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon6],PlayerInfo[i][Ammo6]);
				    }
			    }
			    case 35..38:
			    {
			    	if(PlayerInfo[i][Ammo7] > ammo)
				    {
				        PlayerInfo[i][Ammo7] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo7] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon7],PlayerInfo[i][Ammo7]);
				    }
			    }
			    case 41..42:
			    {
			    	if(PlayerInfo[i][Ammo9] > ammo)
				    {
				        PlayerInfo[i][Ammo9] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo9] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon9],PlayerInfo[i][Ammo9]);
				    }
			    }
			    case 44..46:
			    {
			    	if(PlayerInfo[i][Ammo11] > ammo)
				    {
				        PlayerInfo[i][Ammo11] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo11] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon11],PlayerInfo[i][Ammo11]);
				    }
			    }
			    case 39:
			    {
			    	if(PlayerInfo[i][Ammo8] > ammo)
				    {
				        PlayerInfo[i][Ammo8] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo8] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon8],PlayerInfo[i][Ammo8]);
				    }
			    }
			    case 40:
			    {
			    	if(PlayerInfo[i][Ammo12] > ammo)
				    {
				        PlayerInfo[i][Ammo12] = ammo;
				    }
				    else if(PlayerInfo[i][Ammo12] < ammo)
				    {
		            SetPlayerAmmo(i,PlayerInfo[i][Weapon12],PlayerInfo[i][Ammo12]);
				    }
			    }
	    	}
		}
		
		if(IsPlayerInAnyVehicle(i))
		{
		    new Float:x,Float:y,Float:z,string[128];
			format(string,sizeof(string),"SPEED:%dKm/h",GetVehicleSpeed(GetPlayerVehicleID(i)));
			PlayerTextDrawSetString(i,TextVehicle4,string);
			PlayerTextDrawShow(i,TextVehicle4);
			format(string,sizeof(string),"Tankpart:%d",CarData[GetPlayerVehicleID(i)][vTankpart]);
			PlayerTextDrawSetString(i,TextVehicle6,string);
			PlayerTextDrawShow(i,TextVehicle6);
			format(string,sizeof(string),"Engine:%d",CarData[GetPlayerVehicleID(i)][vEngine]);
			PlayerTextDrawSetString(i,TextVehicle2,string);
			PlayerTextDrawShow(i,TextVehicle2);
			if(CarData[GetPlayerVehicleID(i)][vEngine] == 0)
			{
			ToggleVehicleEngine(GetPlayerVehicleID(i), false);
			}
			else
			{
				if(CarData[GetPlayerVehicleID(i)][vFuel] > 0)
				{
				ToggleVehicleEngine(GetPlayerVehicleID(i), true);
				}
				else
				{
				ToggleVehicleEngine(GetPlayerVehicleID(i), false);
				}
			}
			GetPlayerPos(i,x,y,z);
			CarData[GetPlayerVehicleID(i)][vPosX] = x;
			CarData[GetPlayerVehicleID(i)][vPosY] = y;
			CarData[GetPlayerVehicleID(i)][vPosZ] = z;
			return SaveVehicles();
		}
		if(GetPlayerWeapon(i) == 15)
		{
		SetPlayerAttachedObject(i,SLOT_TOY1, 2590, 6, 0.090999, 0.010000, -0.170000, -177.300003, 2.300004, -142.800018, 1.095000, 1.266000, 0.560000, 0, 0);
		}
		else
		{
		RemovePlayerAttachedObject(i,SLOT_TOY1);
		}
		
	}
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == Dialog_Craft)
	{
		if(!response) return 1;
		if(listitem == 0)
		{
		    if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,COLOR_TEAM2,"Inventory Full");
		    if(GetItemAmount(playerid,I_VatLieu) >= 5)
		    {
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    AddInventoryItem(playerid,I_Gate,1);
		    }
		    else
		    {
		    SendMessage(playerid,COLOR_TEAM2,"You need 5 material to craft gate","Ban can 5 goi vat lieu de che tao gate");
		    }
			return 1;
		}
		if(listitem == 1)
		{
		    if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,COLOR_TEAM2,"Inventory Full");
		    if(GetItemAmount(playerid,I_Wood) >= 10)
		    {
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    AddInventoryItem(playerid,I_Metal,1);
		    }
		    else
		    {
		    SendMessage(playerid,COLOR_TEAM2,"You need 10 wood to craft metal","Ban can 10 dong go de che tao tuong");
		    }
		    
		}
		if(listitem == 2)
		{
			if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,COLOR_TEAM2,"Inventory Full");
		    if(GetItemAmount(playerid,I_Wood) >= 5)
		    {
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    RemoveInventoryItem(playerid,I_Wood);
		    AddInventoryItem(playerid,I_Ladder,1);
		    }
		    else
		    {
		    SendMessage(playerid,COLOR_TEAM2,"You need 5 wood to craft ladder","Ban can 5 dong go de che tao cau thang");
		    }
		}
		if(listitem == 3)
		{
		    if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,COLOR_TEAM2,"Inventory Full");
		    if(GetItemAmount(playerid,I_VatLieu) >= 10)
		    {
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    RemoveInventoryItem(playerid,I_VatLieu);
		    AddInventoryItem(playerid,I_Keypad,1);
		    }
		    else
		    {
		    SendMessage(playerid,COLOR_TEAM2,"You need 10 material to craft Keypad","Ban can 10 goi vat lieu de che tao keypad");
		    }
			return 1;
		}
		if(listitem == 4)
		{
		    if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,COLOR_TEAM2,"Inventory Full");
		    if(GetItemAmount(playerid,I_VatLieu) >= 1)
		    {
		    RemoveInventoryItem(playerid,I_VatLieu);
		    AddInventoryItem(playerid,I_Lighter,1);
		    }
		    else
		    {
		    SendMessage(playerid,COLOR_TEAM2,"You need 1 material to craft Lighter","Ban can 1 goi vat lieu de che tao Lighter");
		    }
			return 1;
		}
	}
	if(dialogid == DIALOG_LOGIN)
	{
		if(!response) return Kick(playerid);
		new string[128];format(string,sizeof(string),"Warz/User/%s.dt",GetName(playerid));
		file_Open(string);
		PlayerInfo[playerid][Password] = file_GetVal("Password");
		file_Close();
     	if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
     	{
			LoadDatabase(playerid);
		}
		else
		{
		    ShowPlayerDialog(playerid,DIALOG_LOGIN,3,"LOGIN","Wrong Password","Login","Quit");
		}
	}
	if(dialogid == DIALOG_REGISTER)
	{
		if(!response) return Kick(playerid);
		if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"REGISTER","WELLCOME TO THE WORLD WAZ [Z]\n Enter Password","Register","Quit");
		new string[128];format(string,sizeof(string),"Warz/User/%s.dt",GetName(playerid));
  		file_Create(string);
  		file_Open(string);
		file_SetVal("Password",udb_hash(inputtext));
		file_Save(string);
		file_Close();
		PlayerInfo[playerid][Mission] = 1;
		PlayerInfo[playerid][EXP] = 0;
		PlayerInfo[playerid][NEXP] = 100;
		PlayerInfo[playerid][MSlot] = 14;
		PlayerInfo[playerid][IsSpawn] = 0;
		SpawnPlayer(playerid);
		ShowPlayerDialog(playerid,DIALOG_LANGUAGE,0,"Language|NgonNgu","Please choose| Vui long chon","English","VietNam");
	}
	if(dialogid == DIALOG_LANGUAGE)
	{
	    if(response) return PlayerInfo[playerid][Language] = 1;
	    if(!response) return PlayerInfo[playerid][Language] = 2;
	}
	if(dialogid == DIALOG_BOX)
	{
		if(!response) return 1;
		if(response)
		{
			if(listitem == 0) return ShowBox(playerid);
			if(listitem == 1)
			{
				for( new i = 0; i < MAX_BOXS;i++)
				{
					if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][bPosX],BoxInfo[i][bPosY],BoxInfo[i][bPosZ]))
					{
					new Float:x,Float:y,Float:z;
					GetPlayerPos(playerid,x,y,z);
					CreateItem(ITEMBOX,1,x,y,z-1,0,0,0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
					DeleteBox(i);
					PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
					}
				}
			}

		}
	}
	if(dialogid == DIALOG_INV)
	{
	    if(response)
	    {
			if(listitem == 0)
			{
				if(GetPVarInt(playerid,"MODELIDINV") > 320 && GetPVarInt(playerid,"MODELIDINV") < 372)
				{
				new weapon,ammo;
				new weaponid =GetModelWeapon(GetPVarInt(playerid,"MODELIDINV"));
				if(weaponid == 22 || weaponid == 23 || weaponid == 24)
				{
					GetPlayerWeaponData(playerid,2,weapon,ammo);
					if(weapon == 0 || weapon == weaponid)
					{
					SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
					RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You already have this type weapon","Ban da co weapon o slot nay");
					}
				}
				else if(weaponid == 25 || weaponid == 26 || weaponid == 27)
				{
					GetPlayerWeaponData(playerid,3,weapon,ammo);
					if(weapon == 0 || weapon == weaponid)
					{
					SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
					RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You already have this type weapon","Ban da co weapon o slot nay");
					}
				}
				else if(weaponid == 28 || weaponid == 29 || weaponid == 32)
				{
					GetPlayerWeaponData(playerid,4,weapon,ammo);
					if(weapon == 0 || weapon == weaponid)
					{
					SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
					RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You already have this type weapon","Ban da co weapon o slot nay");
					}
				}
				else if(weaponid == 30 || weaponid == 31)
				{
					GetPlayerWeaponData(playerid,5,weapon,ammo);
					if(weapon == 0 || weapon == weaponid)
					{
					SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
					RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You already have this type weapon","Ban da co weapon o slot nay");
					}
				}
				else if(weaponid == 33 || weaponid == 34)
				{
					GetPlayerWeaponData(playerid,6,weapon,ammo);
					if(weapon == 0 || weapon == weaponid)
					{
					SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
					RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You already have this type weapon","Ban da co weapon o slot nay");
					}
				}
				else
				{
				SetPlayerWeapon(playerid,weaponid,GetPVarInt(playerid,"INVIAMOUNT"));
				RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
				}
				
				SetPVarInt(playerid,"MODELIDINV",0);
				SetPVarInt(playerid,"INVIAMOUNT",0);
				}
				CallLocalFunction("OnPlayerUseItem","ddd",playerid,GetPVarInt(playerid,"MODELIDINV"),GetPVarInt(playerid,"INVIAMOUNT"));
			}
			if(listitem == 1)
			{
				new Float:x,Float:y,Float:z;
				GetPlayerPos(playerid,x,y,z);// 
				if(GetPVarInt(playerid,"MODELIDINV") == I_Bag)
				{
				CreateItem(GetPVarInt(playerid,"MODELIDINV"),GetPVarInt(playerid,"INVIAMOUNT"),x,y,z-0.8,272.63983, 56.52002, 52.32000,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
				}
				else
				{
				CreateItem(GetPVarInt(playerid,"MODELIDINV"),GetPVarInt(playerid,"INVIAMOUNT"),x,y,z-0.8,0,0,0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
				}
				RemoveInventoryItem(playerid,GetPVarInt(playerid,"MODELIDINV"));
				SetPVarInt(playerid,"MODELIDINV",0);
				SetPVarInt(playerid,"INVIAMOUNT",0);
				ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",3.0,0,0,0,0,0);
			}
		}
		else
		{
		ShowInventory(playerid);
		}
	}
	if(dialogid == Dialog_SetupPass)
	{
	    if(!response) return 1;
	    new string[128];
		BuildInfo[PlayerUseingBuild[playerid]][bdPass] = udb_hash(inputtext);
		format(string,sizeof(string),"Password setup is : %s ",inputtext);
		PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		RemoveInventoryItem(playerid,I_Keypad);
		SendClientMessage(playerid,-1,string);
		SaveBuild(PlayerUseingBuild[playerid]);
	}
	if(dialogid == DIALOG_GATE)
	{
	    if(!response) return 1;

	    if(listitem == 0)
	    {
		ShowDialog(playerid,Dialog_EnterPass,1,"Enter Password","Nhap mat khau","Please enter password to open gate","Vui long nhap mat khau de mo cua ","Enter","Close");
	    }
	    if(listitem == 1)
	    {
	    MoveDynamicObject(BuildInfo[PlayerUseingBuild[playerid]][bdObject], BuildInfo[PlayerUseingBuild[playerid]][bdX], BuildInfo[PlayerUseingBuild[playerid]][bdY],BuildInfo[PlayerUseingBuild[playerid]][bdZ],4);
	    //SetDynamicObjectPos(BuildInfo[PlayerUseingBuild[playerid]][bdObject], BuildInfo[PlayerUseingBuild[playerid]][bdX], BuildInfo[PlayerUseingBuild[playerid]][bdY],BuildInfo[PlayerUseingBuild[playerid]][bdZ]);
	    }

	}
	if(dialogid == Dialog_EnterPass)
	{
	    if(!response) return 1;
	    if(udb_hash(inputtext) == BuildInfo[PlayerUseingBuild[playerid]][bdPass])
	    {
	    MoveDynamicObject(BuildInfo[PlayerUseingBuild[playerid]][bdObject],BuildInfo[PlayerUseingBuild[playerid]][bdX], BuildInfo[PlayerUseingBuild[playerid]][bdY],BuildInfo[PlayerUseingBuild[playerid]][bdZ]-5,3);
		//SetDynamicObjectPos(BuildInfo[PlayerUseingBuild[playerid]][bdObject],BuildInfo[PlayerUseingBuild[playerid]][bdX], BuildInfo[PlayerUseingBuild[playerid]][bdY],BuildInfo[PlayerUseingBuild[playerid]][bdZ]-5);
	    }
	    else
	    {
	    ShowDialog(playerid,Dialog_EnterPass,1,"Enter Password","Nhap mat khau","Wrong password\nPlease enter password to open gate","Sai mat khau \nVui long nhap mat khau de mo cua","Enter","Close");
	    }
	}
	if(dialogid == DIALOG_EDITBD)
	{
        if(!response) return 1;
		if(listitem == 0)
		{
			EditDynamicObject(playerid, BuildInfo[PlayerUseingBuild[playerid]][bdObject]);
		}
		if(listitem == 1)
		{
		    BuildInfo[PlayerUseingBuild[playerid]][bdLock] = 1;
		    SaveBuild(PlayerUseingBuild[playerid]);
		}
		if(listitem == 2)
		{
		    BuildInfo[PlayerUseingBuild[playerid]][bdLock] = 0;
		    SaveBuild(PlayerUseingBuild[playerid]);
		}
	}
	if(dialogid == Dialog_GetRangeBuild)
	{
		if(!response) return 1;
      	new string[256];
     	PlayerUseingBuild[playerid] = ShowPlayerRangeBuild[playerid][listitem];
		format(string, sizeof(string), "[Build ID]: %d", BuildInfo[PlayerUseingBuild[playerid]][bdID]);
       	ShowPlayerDialog(playerid, DIALOG_EDITBD, DIALOG_STYLE_LIST, string, "Edit Position\nLock\nUnLock", "Select", "Close");
	}
	return 1;
}
stock Float:RandomFloat(Float:min, Float:max, accuracy = 4)
{
	if (min >= max) return 0.0;
	if (min < 0.0 || max < 0.0) return 0.0;
	if (accuracy < 1 || accuracy > 6) return 0.0;
	new divValue;
	switch (accuracy) {
		case 1: divValue = 10;
		case 2: divValue = 100;
		case 3: divValue = 1000;
		case 4: divValue = 10000;
		case 5: divValue = 100000;
		case 6: divValue = 1000000;
	}
	return random(floatround(max) - floatround(min)) + min + (random(divValue) / divValue);
}

stock SetVehicleHealthEx(vehicleid,Float:health)
{
	CarData[vehicleid][vHealth] = health;
	SetVehicleHealth(vehicleid,health);
}
forward OnPlayerUseItem(playerid,modelid,amount);
public OnPlayerUseItem(playerid,modelid,amount)
{
	if(modelid == I_Gate)
	{
	    if(GetPlayerItem(playerid,I_Hammer))
	    {
			new Model, Float:x, Float:y, Float:z;
			new NewID = GetBuildID();
			Model = I_Gate;

			if(NewID == -1) return SendClientMessage(playerid, 0xFF0000C8, "* No extra Build that you can not continue to create.");

			GetPlayerPos(playerid,x,y,z);
			BuildInfo[NewID][bdLock] = 0;
			BuildInfo[NewID][bdID] = NewID;
			BuildInfo[NewID][bdModel] = Model;
			BuildInfo[NewID][bdX] = x +1;
			BuildInfo[NewID][bdY] = y +1;
			BuildInfo[NewID][bdZ] = z;
			BuildInfo[NewID][bdRX] = 0;
			BuildInfo[NewID][bdRY] = 0;
			BuildInfo[NewID][bdRZ] = 0;
			BuildInfo[NewID][bdvID] = GetPlayerVirtualWorld(playerid);
			BuildInfo[NewID][bdInt] = GetPlayerInterior(playerid);
			CreateBuild(NewID);
			SaveBuild(NewID);
			RemoveInventoryItem(playerid,modelid);
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You need item Hammer to build","Ban can item hammer de xay");
	}
	if(modelid == I_Ladder)
	{
		if(GetPlayerItem(playerid,I_Hammer))
	    {
			new Model, Float:x, Float:y, Float:z;
			new NewID = GetBuildID();
			Model = I_Ladder;

			if(NewID == -1) return SendClientMessage(playerid, 0xFF0000C8, "* No extra Build that you can not continue to create.");

			GetPlayerPos(playerid,x,y,z);
			BuildInfo[NewID][bdLock] = 0;
			BuildInfo[NewID][bdID] = NewID;
			BuildInfo[NewID][bdModel] = Model;
			BuildInfo[NewID][bdX] = x +1;
			BuildInfo[NewID][bdY] = y +1;
			BuildInfo[NewID][bdZ] = z;
			BuildInfo[NewID][bdRX] = 0;
			BuildInfo[NewID][bdRY] = 0;
			BuildInfo[NewID][bdRZ] = 0;
			BuildInfo[NewID][bdvID] = GetPlayerVirtualWorld(playerid);
			BuildInfo[NewID][bdInt] = GetPlayerInterior(playerid);
			CreateBuild(NewID);
			SaveBuild(NewID);
			RemoveInventoryItem(playerid,modelid);
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You need item Hammer to build","Ban can item hammer de xay");
	}
	if(modelid == I_Metal)
	{
		if(GetPlayerItem(playerid,I_Hammer))
	    {
			new Model, Float:x, Float:y, Float:z;
			new NewID = GetBuildID();
			Model = I_Metal;

			if(NewID == -1) return SendClientMessage(playerid, 0xFF0000C8, "* No extra Build that you can not continue to create.");

			GetPlayerPos(playerid,x,y,z);
			BuildInfo[NewID][bdLock] = 0;
			BuildInfo[NewID][bdID] = NewID;
			BuildInfo[NewID][bdModel] = Model;
			BuildInfo[NewID][bdX] = x +1;
			BuildInfo[NewID][bdY] = y +1;
			BuildInfo[NewID][bdZ] = z;
			BuildInfo[NewID][bdRX] = 0;
			BuildInfo[NewID][bdRY] = 0;
			BuildInfo[NewID][bdRZ] = 0;
			BuildInfo[NewID][bdvID] = GetPlayerVirtualWorld(playerid);
			BuildInfo[NewID][bdInt] = GetPlayerInterior(playerid);
			CreateBuild(NewID);
			SaveBuild(NewID);
			RemoveInventoryItem(playerid,modelid);
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You need item Hammer to build","Ban can item hammer de xay");
	}
	if(modelid == I_Bag)
	{
	    if(amount > PlayerInfo[playerid][MSlot])
	    {
		SetPlayerInventorySlot(playerid,amount);
		RemoveInventoryItem(playerid,modelid);
	    }
	    else
	    {
	    SendMessage(playerid,COLOR_TEAM2,"Slot this bag is small","Cai cap nay nho hon cua ban");
	    }
	}
	if(modelid == I_Wood)
	{
	    if(GetPlayerItem(playerid,I_Lighter) == 1)
	    {
		new
			Float:x,
			Float:y,
			Float:z,
			Float:rz;
		GetPlayerFacingAngle(playerid,rz);
		GetPlayerPos(playerid, x, y, z);

		CreateFire(x + floatsin(-rz, degrees), y + floatcos(-rz, degrees), z - 0.85);
		RemoveInventoryItem(playerid,modelid);
		PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You need lighter to make fire","Ban can bat lua de su dung go");
	}
	if(modelid == ITEMBOX)
	{
	CreateBox(playerid);
	RemoveInventoryItem(playerid,modelid);
	PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	}
	if(modelid == I_Medkit)
	{
	PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	SetPlayerHP(playerid,100);
	RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Bandage)
	{
	    if(PlayerInfo[playerid][Bleed] == 0) return SendMessage(playerid,COLOR_TEAM1,"You not bleeding","Ban khong bi chay mau");
	    PlayerInfo[playerid][Bleed] = 0;
	    PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Pills)
	{
		if(PlayerInfo[playerid][Broken] == 0) return SendMessage(playerid,COLOR_TEAM1,"You not broken leg","Ban khong bi gay chan");
	    PlayerInfo[playerid][Broken] = 0;
	    SetPlayerDrunkLevel(playerid,0);
	    PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	    return 1;
	}
	if(modelid == I_AntiVirus)
	{
		if(PlayerInfo[playerid][Virus] == 0) return SendMessage(playerid,COLOR_TEAM1,"You not virus infection","Ban khong bi nhiem virus");
	    PlayerInfo[playerid][Virus] = 0;
	    SetPlayerDrunkLevel(playerid,0);
	    PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Cloth)
	{
	    RemoveInventoryItem(playerid,modelid);
	    AddInventoryItem(playerid,modelid,GetPlayerSkin(playerid));
	    SetPlayerSkinEx(playerid,amount);
	    
	}
	if(modelid == I_ToolBox)
	{
	    SetVehicleHealthEx(CarID(playerid),900);
	}
	if(modelid == I_Engine)
	{
	    if(CarData[CarID(playerid)][vEngine] == 1) return SendMessage(playerid,COLOR_TEAM2,"This vehicle has already Engine","Chiec xe nay da co dong co");
	    CarData[CarID(playerid)][vEngine] = 1;
	    SendMessage(playerid,COLOR_TEAM1,"Install Engine","Cai dat dong co");
	    PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Wheel)
	{
	    	if(GetBanhXe(CarID(playerid)) == 4) return SendMessage(playerid,COLOR_TEAM2,"This vehicle has already full Tire","Chiec xe nay da co du banh xe");
			SetCarTireState(CarID(playerid),CAR_BANHTRUOC_TRAI,0);
			SetCarTireState(CarID(playerid),CAR_BANHSAU_TRAI,0);
			SetCarTireState(CarID(playerid),CAR_BANHTRUOC_PHAI,0);
			SetCarTireState(CarID(playerid),CAR_BANHSAU_PHAI,0);
			SendMessage(playerid,COLOR_TEAM1,"Install Wheel","Lap dat banh xe moi");
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    	RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Tankpart)
	{
		if(CarData[CarID(playerid)][vTankpart] == 1) return SendMessage(playerid,COLOR_TEAM2,"This vehicle has already Tankpart","Chiec xe nay da co binh phun xang F1");
	    CarData[CarID(playerid)][vTankpart] = 1;
	    SendMessage(playerid,COLOR_TEAM1,"Install TankPart","Cai dat Phun Xang F1");
	    PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Pizza || modelid == I_Burger || modelid == I_Taco || modelid == I_Hotdog)
	{
	    if(amount == 1)
	    {
	    PlayerInfo[playerid][Hunger] += RandomFloat(50.5,70.5,4);
	    }
	    else
	    {
	    PlayerInfo[playerid][Hunger] += RandomFloat(20.5,40.6,4);
	    }
	    ApplyAnimation(playerid, "FOOD", "EAT_Burger", 4.1, 0, 0, 0, 0, 0);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_SodaCan || modelid == I_Pesi || modelid == I_NuocCam)
	{
	    PlayerInfo[playerid][Thirst] += RandomFloat(70.5,90.5,4);
	    ApplyAnimation(playerid, "BAR", "dnk_stndM_loop", 3.0, 0, 1, 1, 0, 0, 1);
	    RemoveInventoryItem(playerid,modelid);
	}
	if(modelid == I_Bottle)
	{
	    if(amount == 1)
	    {
		    PlayerInfo[playerid][Thirst] += RandomFloat(50.5,100.0,4);
		    RemoveInventoryItem(playerid,modelid);
		    AddInventoryItem(playerid,modelid,0);
	    }
	    else
	    {
	    	SendMessage(playerid,-1,"Empty","Het nuoc");
	    }
	}
	new weaponid = GetPlayerWeapon(playerid);
	if(modelid == I_AmmoSlot2)
	{
		if(weaponid == 22 || weaponid == 23 || weaponid == 24)
		{
		    PlayAnim(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
			SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_AmmoSlot3)
	{
		if(weaponid == 25 || weaponid == 26 || weaponid == 27)
		{
		    PlayAnim(playerid, "BUDDY", "buddy_reload", 4.0, 0, 0, 0, 0, 0, 1);
		    SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
		}
		else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_AmmoSlot4)
	{
	    if(weaponid == 28 || weaponid == 29 || weaponid == 32)
	    {
		    PlayAnim(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
			SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
	    }
	    else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_AmmoSlot5)
	{
		if(weaponid == 30 || weaponid == 31)
	    {
		    PlayAnim(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
			SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
	    }
	    else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_AmmoSlot6)
	{
		if(weaponid == 33 || weaponid == 34)
	    {
		    PlayAnim(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
			SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
	    }
	    else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_AmmoSlot7)
	{
		if(weaponid == 35 || weaponid == 36|| weaponid == 37|| weaponid == 38)
	    {
		    PlayAnim(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
			SetPlayerWeapon(playerid,weaponid,amount);
			RemoveInventoryItem(playerid,modelid);
	    }
	    else return SendMessage(playerid,COLOR_TEAM2,"You no have weapon for this ammo","Dan khong phu hop voi sung");
	}
	if(modelid == I_GasCan)
	{
		if(amount == 1)
		{
			for(new i = 1 ; i < MAX_VEHICLES;i++)
			{
			    new Float:x,Float:y,Float:z;
			    GetVehiclePos(i,x,y,z);
			    if(IsPlayerInRangeOfPoint(playerid,3,x,y,z))
			    {
				CarData[i][vFuel] += 50.0;
				if(CarData[i][vFuel] > 100.0)
				{
				CarData[i][vFuel] = 100.0;
				}
				RemoveInventoryItem(playerid,modelid);
				AddInventoryItem(playerid,modelid,0);
				break;
			    }
			}
		}
		else
		{
		    SendMessage(playerid,COLOR_TEAM2,"Empty Petrol Can","Het xang");
		}
	}
	return 1;
}
stock CarID(playerid)
{
			new id;
			for(new i = 1 ; i < MAX_VEHICLES;i++)
			{
			    new Float:x,Float:y,Float:z;
			    GetVehiclePos(i,x,y,z);
			    if(IsPlayerInRangeOfPoint(playerid,3,x,y,z))
			    {
				id = i;
			    }
			}
			return id;
}
public OnPlayerDisconnect(playerid, reason)
{
	if(!IsPlayerNPC(playerid))
	{
	SaveDatabase(playerid);
	}
	return 1;
}
public OnPlayerSpawn(playerid)
{
    SetPlayerTime(playerid, 0, 0); 
    SetPlayerWeather(playerid, 42);
	SetPlayerHealth(playerid,100);
    GangZoneShowForPlayer(playerid,RedRadar,0xFF000096);
    for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
    for(new i =0; i < 8; i ++)
	{
		TextDrawHideForPlayer(playerid,TextConnect[i]);
	}
    SetPlayerSkillLevel(playerid,0,0);

	if (IsPlayerNPC(playerid))
	{
	    new nname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, nname, sizeof(nname));
		RNPC_SetShootable(playerid, 1);
		RNPC_ToggleVehicleCollisionCheck(playerid, 1);
		new Random = random(sizeof(RandomZSpawns));
    	SetPlayerPos(playerid, RandomZSpawns[Random][0], RandomZSpawns[Random][1], RandomZSpawns[Random][2]);
    	SetPlayerFacingAngle(playerid, RandomZSpawns[Random][3]);
    	switch(random(2))
    	{
		case 0:SetPlayerSkin(playerid,162);
		case 1:SetPlayerSkin(playerid,264);
		}
		
		SetPlayerColor(playerid,0xFF0000FF);
		SetPVarInt(playerid,"IsABot",0);
		SetPlayerAttachedObject(playerid, 0, 18729, 1, -0.093999, 0.037999, 1.622999, -175.500015, 0.000000, -91.999984, 1.880999, 0.694999, 1.016000, 0, 0);
		SetPlayerAttachedObject(playerid, 1, 2806, 1, 0.035000, 0.053999, 0.000000, 80.400039, -16.199991, -81.199989, 0.696000, 0.660999, 1.046999, 0, 0);
		SetPlayerAttachedObject(playerid, 2, 2805, 1, 0.058999, -0.172999, 0.000000, 0.000000, 89.399986, 0.000000, 0.731000, 1.000000, 0.523999, 0, 0);
		SetPlayerAttachedObject(playerid, 3, 2806, 7, 0.294999, 0.000000, 0.000000, -9.299998, -0.000000, 107.799995, 0.511000, 0.612999, 0.563999, 0, 0);
		SetPlayerAttachedObject(playerid, 4, 2806, 2, 0.003999, 0.002999, 0.000000, 0.000000, 0.000000, 0.000000, 0.679000, 0.227999, 0.440000, 0, 0);
		SetPlayerAttachedObject(playerid, 5, 341, 5, -0.090999, -0.035999, 0.205000, -15.499999, 48.400001, 12.500000, 1.000000, 1.000000, 1.000000, 0, 0);
		SetPlayerAttachedObject(playerid, 6, 2806, 5, 0.044000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.683000, 0.298000, 0.962000, 0, 0);
		SetPlayerAttachedObject(playerid, 7, 2908, 1, 0.260000, -0.245000, -0.013000, 88.500007, 87.599983, 0.000000, 1.000000, 1.000000, 1.000000, 0, 0);
		
	}
	else
	{
		if(PlayerInfo[playerid][IsSpawn] == 1)
		{
		    SetPlayerSkinEx(playerid,PlayerInfo[playerid][Skin]);
		    SetPlayerPos(playerid,PlayerInfo[playerid][px],PlayerInfo[playerid][py],PlayerInfo[playerid][pz]);
		    SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VW]);
		    SetPlayerInterior(playerid,PlayerInfo[playerid][Int]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon1],PlayerInfo[playerid][Ammo1]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon2],PlayerInfo[playerid][Ammo2]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon3],PlayerInfo[playerid][Ammo3]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon4],PlayerInfo[playerid][Ammo4]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon5],PlayerInfo[playerid][Ammo5]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon6],PlayerInfo[playerid][Ammo6]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon7],PlayerInfo[playerid][Ammo7]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon8],PlayerInfo[playerid][Ammo8]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon9],PlayerInfo[playerid][Ammo9]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon10],PlayerInfo[playerid][Ammo10]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon11],PlayerInfo[playerid][Ammo11]);
		    SetPlayerWeapon(playerid,PlayerInfo[playerid][Weapon12],PlayerInfo[playerid][Ammo12]);
	    	SetPlayerHealth(playerid,PlayerInfo[playerid][Blood]);
	    	SetBagObject(playerid);
 			SetPVarInt(playerid,"StartCheck",1);
		    
		}
		if(PlayerInfo[playerid][IsSpawn] == 0)
		{
		    PlayerInfo[playerid][MSlot] = 14;
		    SetPlayerHP(playerid,100);
		    PlayerInfo[playerid][Temp] = 100;
		    PlayerInfo[playerid][Hunger] = 80.5;
		    PlayerInfo[playerid][Thirst] = 70.0;
    		PlayerInfo[playerid][MaxBlood] = 100.0;
    		SetPVarInt(playerid,"StartCheck",1);
    		SetPlayerWeapon(playerid,46,1);
    		SetPlayerWeapon(playerid,15,1);
		    switch(random(3))
		    {
			    case 0:
			    {
			    SetPlayerSkinEx(playerid,45);
				SetPlayerPos(playerid,200.3112,1374.2012,757.1565);
				}
			    case 1:
			    {
			    SetPlayerSkinEx(playerid,252);
				SetPlayerPos(playerid,12.7130,1555.9945,14.3342);
				}
			    case 2:
				{
				SetPlayerSkinEx(playerid,97);
				SetPlayerPos(playerid,-279.4388,-1327.9475,572.7411);
			    }
		    }
   			PlayerInfo[playerid][IsSpawn] = 1;
   			SetBagObject(playerid);
		
		}
	}
	if(FPSSMONE == 1)
	{
		fps_ObjectID[playerid] = CreateObject(19300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
		AttachObjectToPlayer(fps_ObjectID[playerid], playerid, 0.0, 0.18, 0.85, 0.0, 0.0, 0.0);
		AttachCameraToObject(playerid, fps_ObjectID[playerid]);
		fps_Active[playerid] = true;
		fps_Timer[playerid] = SetTimerEx("CrouchCheck",50,1,"i",playerid);
	}
	else if(FPSSMONE == 0)
	{
		DestroyObject(fps_ObjectID[playerid]);
		KillTimer(fps_Timer[playerid]);
		SetCameraBehindPlayer(playerid);
		fps_Active[playerid] = false;
	}
	return 1;
}
forward BatDauCheck(playerid);
public BatDauCheck(playerid)
{
	SetPlayerHealth(playerid,PlayerInfo[playerid][Blood]);
 	SetPVarInt(playerid,"StartCheck",1);
 	return 1;
}
stock StatsText(playerid)
{
	new string[128];
	format(string,sizeof(string),"Murder:%d",PlayerInfo[playerid][Kill]);
	PlayerTextDrawSetString(playerid,Textdraw1,string);
	format(string,sizeof(string),"HShoot:%d",PlayerInfo[playerid][HShoot]);
	PlayerTextDrawSetString(playerid,Textdraw2,string);
	format(string,sizeof(string),"Zkill:%d",PlayerInfo[playerid][ZKill]);
	PlayerTextDrawSetString(playerid,Textdraw3,string);
	
	format(string,sizeof(string),"Level:%d",PlayerInfo[playerid][Level]);
	PlayerTextDrawSetString(playerid,Textdraw13,string);
	
	PlayerTextDrawShow(playerid,Textdraw0);
	PlayerTextDrawShow(playerid,Textdraw1);
	PlayerTextDrawShow(playerid,Textdraw2);
	PlayerTextDrawShow(playerid,Textdraw3);
	PlayerTextDrawShow(playerid,Textdraw4);
	PlayerTextDrawShow(playerid,Textdraw5);
	PlayerTextDrawShow(playerid,Textdraw6);
	PlayerTextDrawShow(playerid,Textdraw7);
	PlayerTextDrawShow(playerid,Textdraw8);
	PlayerTextDrawShow(playerid,Textdraw9);
	PlayerTextDrawShow(playerid,Textdraw10);
	PlayerTextDrawShow(playerid,Textdraw11);
	PlayerTextDrawShow(playerid,Textdraw12);
	PlayerTextDrawShow(playerid,Textdraw13);
	PlayerTextDrawShow(playerid,Textdraw14);
	PlayerTextDrawShow(playerid,Textdraw15);
	if(PlayerInfo[playerid][Broken] == 1)
	{
	PlayerTextDrawShow(playerid,Textdraw16);
	}
	else
	{
	PlayerTextDrawHide(playerid,Textdraw16);
	}
	if(PlayerInfo[playerid][Bleed] == 1)
	{
	PlayerTextDrawShow(playerid,Textdraw17);
	}
	else
	{
	PlayerTextDrawHide(playerid,Textdraw17);
	}
 	if(PlayerInfo[playerid][Virus] == 1)
	{
	PlayerTextDrawShow(playerid,Textdraw18);
	}
	else
	{
	PlayerTextDrawHide(playerid,Textdraw18);
	}
	PlayerTextDrawShow(playerid,Textdraw19);
	PlayerTextDrawShow(playerid,Textdraw20);
	PlayerTextDrawShow(playerid,Textdraw21);
	PlayerTextDrawShow(playerid,Textdraw22);
	PlayerTextDrawShow(playerid,Textdraw23);
	return 1;
}
stock Float:GetDistanceBetweenPlayers(playerid,targetplayerid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetplayerid)) {
        return -1.00;
    }
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(targetplayerid,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
timer UpdateZombiePunch[300]()
{
    foreach(Player, i)
    {
	    if(!IsPlayerNPC(i))
	    {
			if (IsPlayerConnected(i))
			{
			    new Float:zx,Float:zy,Float:zz;//,Float:Angle;
			    for(new npcid = 0; npcid < MAX_PLAYERS;npcid++)
			    {
			        if(IsPlayerNPC(npcid))
			        {
			            if(GetPVarInt(npcid,"IsABot") == 0)
			            {
			       			GetPlayerPos(i,zx,zy,zz);
							if(GetDistanceBetweenPlayers(npcid,i) < 1)//if(IsPlayerInRangeOfPoint(i,2,zx,zy,zz))
							{
								if(GetRNPCHealth(npcid) > 0)
								{
								SetPlayerPos(npcid,zx,zy,zz);
								RNPC_CreateBuild(npcid,PLAYER_RECORDING_TYPE_ONFOOT);
								SetPlayerLookAt(npcid,zx,zy);
								RNPC_AddPause(500);
								RNPC_SetKeys(KEY_FIRE);
								RNPC_AddPause(500);
								RNPC_SetKeys(0);
								RNPC_FinishBuild();
								RNPC_StartBuildPlayback(npcid);
								}
							}
						}
					}
				}
			}
		}
	}
	return 1;
}

public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
	new Float:vhp,string[128]; GetVehicleHealth(vehicleid,vhp);

	CarData[vehicleid][vCTire1] = GetCarTireState(vehicleid,1);
	CarData[vehicleid][vCTire2] = GetCarTireState(vehicleid,2);
	CarData[vehicleid][vCTire3] = GetCarTireState(vehicleid,3);
	CarData[vehicleid][vCTire4] = GetCarTireState(vehicleid,4);
	format(string,sizeof(string),"Tire:%d/4",GetBanhXe(vehicleid));
	PlayerTextDrawSetString(playerid,TextVehicle3,string);
	PlayerTextDrawShow(playerid,TextVehicle3);
	if(vhp > CarData[vehicleid][vHealth] )
	{
		SetVehicleHealth(vehicleid,CarData[vehicleid][vHealth]);
		if(vhp < 400.0)
		{
			SendMessage(playerid,COLOR_TEAM2,"This vehicle has broken","Xe da hu hong qua nang");
			ToggleVehicleEngine(vehicleid, false);
		}
	}
	else
	{
		CarData[vehicleid][vHealth] = vhp;
	}
	return SaveVehicles();
}
public OnPlayerTargetPlayer(playerid, targetid, weaponid)
{
    ShowPlayerNameTagForPlayer(targetid,playerid,true);
	return 1;
}
forward UnBroken(playerid);public UnBroken(playerid)
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	SetPlayerPos(playerid,x,y,z);
	return 1;
}
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
	
	ResetPlayerMoney(playerid);
	GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
 	new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);
   /* if(Keys == KEY_SPRINT || Keys == KEY_JUMP)
    {
        if(PlayerInfo[playerid][Broken] == 1)
        {
        PlayAnim(playerid, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
        SetTimerEx("UnBroken",5000,0,"i",playerid);
        }
    }*/
 	if(GetPlayerAnimationIndex(playerid))
    {
        new animlib[32];
        new animname[32];
        GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        if(strcmp(animlib, "SWIM", true) == 0 && !swimming[playerid])
        {
            swimming[playerid] = true;
        }
        else if(strcmp(animlib, "SWIM", true) != 0 && swimming[playerid] && strfind(animname, "jump", true) == -1)
        {
            swimming[playerid] = false;
        }
    }
    else if(swimming[playerid])
    {
        swimming[playerid] = false;
    }
	if(IsPlayerNPC(playerid))
	{
 		if(IsPlayerInRangeOfPoint(playerid,50,0,0,3))
 		{
   			new nname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, nname, sizeof(nname));
			new Random = random(sizeof(RandomZSpawns));
	    	SetPlayerPos(playerid, RandomZSpawns[Random][0], RandomZSpawns[Random][1], RandomZSpawns[Random][2]);
	    	SetPlayerFacingAngle(playerid, RandomZSpawns[Random][3]);
 		}
	}
	switch(GetPlayerWeapon(playerid))
    {
      case 44, 45:
      {
        GetPlayerKeys(playerid, Keys, ud, lr);
        if((Keys & KEY_FIRE) && (!IsPlayerInAnyVehicle(playerid)))
            {
              return 0;
            }
        }
    }
    return 1;
}
timer UpdateZombieMovement[1000]()
{
	new Float:zx, Float:zy, Float:zz,Float:x, Float:y, Float:z;//,Float:hp;
	foreach(Player, i)
    {
	    if(!IsPlayerNPC(i))
	    {
			if (IsPlayerConnected(i))
			{
				for(new npcid = 0; npcid < MAX_PLAYERS;npcid++)
			    {
			        if(IsPlayerNPC(npcid))
			        {
			            if(GetPVarInt(npcid,"IsABot") == 0)
			            {
							GetPlayerPos(npcid, zx, zy, zz);
							if(IsPlayerInRangeOfPoint(i,MAXZRANGE,zx,zy,zz))
							{
								GetPlayerPos(i,x,y,z);
	     						if(IsPlayerInRangeOfPoint(npcid,5,x,y,z))
	     						{
	     							MoveRNPC(npcid,x,y,z,RNPC_SPEED_RUN, 1);
	     						}
	     						else if(GetPlayerSkin(npcid) == 162)
	     						{
		     						MoveRNPC(npcid, x - 3.0 + random(600) / 100.0,
		     						y - 3.0 + random(600) / 100.0, z, RNPC_SPEED_SPRINT, 1);
	     						}
	     						else if(GetPlayerSkin(npcid) != 162)
	     						{
    								MoveRNPC(npcid, x - 3.0 + random(600) / 100.0,
		     						y - 3.0 + random(600) / 100.0, z, RNPC_SPEED_RUN, 1);
	     						}
							}
							else
							{
							    GetPlayerPos(npcid,x,y,z);
							    MoveRNPC(npcid, x - 3.0 + random(800) / 100.0,
	                        	y - 3.0 + random(800) / 100.0, z, RNPC_SPEED_WALK, 1);
							}
						}
					}
				}
			}
		}
	}
	return 1;
}
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
	new Float:oldX, Float:oldY, Float:oldZ,Float:oldRotX, Float:oldRotY, Float:oldRotZ;
	GetDynamicObjectPos(objectid, oldX, oldY, oldZ);
	GetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);


	if(response == EDIT_RESPONSE_FINAL)
	{
		BuildInfo[PlayerUseingBuild[playerid]][bdX] = x;
		BuildInfo[PlayerUseingBuild[playerid]][bdY] = y;
		BuildInfo[PlayerUseingBuild[playerid]][bdZ] = z;
		BuildInfo[PlayerUseingBuild[playerid]][bdRX] = rx;
		BuildInfo[PlayerUseingBuild[playerid]][bdRY] = ry;
		BuildInfo[PlayerUseingBuild[playerid]][bdRZ] = rz;
		BuildInfo[PlayerUseingBuild[playerid]][bdvID] = GetPlayerVirtualWorld(playerid);
		BuildInfo[PlayerUseingBuild[playerid]][bdInt] = GetPlayerInterior(playerid);
		SetDynamicObjectPos(objectid, x, y, z);
		SetDynamicObjectRot(objectid, rx, ry, rz);
		SaveBuild(BuildInfo[PlayerUseingBuild[playerid]][bdID]);
		PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
	}
	if(response == EDIT_RESPONSE_CANCEL)
	{
		SetDynamicObjectPos(objectid, oldX, oldY, oldZ);
		SetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
		BuildInfo[PlayerUseingBuild[playerid]][bdX] = oldX;
		BuildInfo[PlayerUseingBuild[playerid]][bdY] = oldY;
		BuildInfo[PlayerUseingBuild[playerid]][bdZ] = oldZ;
		BuildInfo[PlayerUseingBuild[playerid]][bdRX] = oldRotX;
		BuildInfo[PlayerUseingBuild[playerid]][bdRY] = oldRotY;
		BuildInfo[PlayerUseingBuild[playerid]][bdRZ] = oldRotZ;
		BuildInfo[PlayerUseingBuild[playerid]][bdvID] = GetPlayerVirtualWorld(playerid);
		BuildInfo[PlayerUseingBuild[playerid]][bdInt] = GetPlayerInterior(playerid);
	}
	SaveBuild(BuildInfo[PlayerUseingBuild[playerid]][bdID]);
}

public OnPlayerFall(playerid, Float:height, Float:damage)
{
	if(damage > 10.0)
	{
	SendMessage(playerid,COLOR_TEAM2,"Broken Leg","Gay Chan");
	PlayerInfo[playerid][Broken] = 1;
	SetPlayerDrunkLevel(playerid,1000);
	}
	return 1;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	// Avoid driveby false alarms
	if (!IsPlayerInAnyVehicle(playerid) && (removeCBugs || alertCBugs))
	{
		new interval = 0;
		switch (weaponid)
		{
			case 24: interval = CBUG_INTERVAL_DEAGLE;
			case 25: interval = CBUG_INTERVAL_SHOTGUN;
			case 27: interval = CBUG_INTERVAL_COMBATSG;
			case 33: interval = CBUG_INTERVAL_COUNTRY;
			case 34: interval = CBUG_INTERVAL_SNIPER;
		}

		// Check if used weapon is a CBug-Weapon
		if (interval > 0) {
			// Check if time difference is positive to avoid GetTickCount-reset false alarms
			if (GetTickCount() - lastDShot[playerid] < interval && GetTickCount() - lastDShot[playerid] >= 0)
			{
				if (alertCBugs) CallLocalFunction("OnPlayerCBug", "iii", playerid, weaponid, GetTickCount() - lastDShot[playerid]);
				return !removeCBugs;
			}
			lastDShot[playerid] = GetTickCount();
		}
	}
	#if defined ACBUG_OnPlayerWeaponShot
		return ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
	#else
		return 1;
	#endif
}
#if defined _ALS_OnPlayerWeaponShot
	#undef OnPlayerWeaponShot
#else
	#define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot ACBUG_OnPlayerWeaponShot
#if defined ACBUG_OnPlayerWeaponShot
    forward ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
#endif
public OnPlayerWeaponEmpty(playerid, weaponid)// new-samp callback
{
    switch(weaponid)
    {
    case 2..9:
    {
    PlayerInfo[playerid][Weapon1] = 0;
    }
    case 10..15:
    {
    PlayerInfo[playerid][Weapon10] = 0;
    }
    case 16..18:
    {
    PlayerInfo[playerid][Weapon8] = 0;
    }
    case 22..24:
    {
    PlayerInfo[playerid][Weapon2] = 0;
    }
    case 25..27:
    {
    PlayerInfo[playerid][Weapon3] = 0;
    }
    case 28..29:
    {
    PlayerInfo[playerid][Weapon4] = 0;
    }
    case 30..31:
    {
    PlayerInfo[playerid][Weapon5] = 0;
    }
    case 32:
    {
    PlayerInfo[playerid][Weapon4] = 0;
    }
    case 33..34:
    {
    PlayerInfo[playerid][Weapon6] = 0;
    }
    case 35..38:
    {
    PlayerInfo[playerid][Weapon7] = 0;
    }
    case 41..42:
    {
    PlayerInfo[playerid][Weapon9] =0;
    }
    case 44..46:
    {
    PlayerInfo[playerid][Weapon11] = 0;
    }
    case 39:
    {
    PlayerInfo[playerid][Weapon8] = 0;
    }
    case 40:
    {
    PlayerInfo[playerid][Weapon12] = 0;
    }
    }
    return 1;
}
public OnPlayerAntiReload(playerid, weaponid)
{
	ResetPlayerWeaponEx(playerid);
	return 1;
}
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(playertextid == TextPutW)
    {
    if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendMessage(playerid,-1,"INVENTORY FULL","Tui do da day");
	if(GetPlayerWeapon(playerid) == 0) return SendMessage(playerid,-1,"No Weapon","Ban khong co sung tren tay");
//	if(GetPlayerWeapon(playerid) > 0 && GetPlayerWeapon(playerid) < 22) return SendMessage(playerid,-1,"Can not put this weapon","Khong the cat vu khi nay");
	AddInventoryItem(playerid,GetWeaponModel(GetPlayerWeapon(playerid)),GetPlayerAmmo(playerid));
	ShowInventory(playerid);
	RemovePlayerWeapon(playerid,GetPlayerWeapon(playerid));
    }
    return 1;
}// 331 371
public OnPlayerModelSelectionEx(playerid, response, extraid,clickslot, modelid)
{
    new string[128];
    if(extraid == INVENTORY_MENU)
    {
        if(response)
        {
        
        if(modelid == 332) return ShowInventory(playerid);
        SetPVarInt(playerid,"MODELIDINV",modelid);
        SetPVarInt(playerid,"INVIAMOUNT",InvInfo[playerid][iAmount][clickslot]);
        format(string,sizeof(string),"|ITEM:%s| AMOUNT: %d|",GetItemName(GetPVarInt(playerid,"MODELIDINV"),GetPVarInt(playerid,"INVIAMOUNT")),GetPVarInt(playerid,"INVIAMOUNT"));
        ShowDialog(playerid,DIALOG_INV,2,string,string,"Use\nDrop","SuDung\nVutRaDat","Ok","Inventory");
        //ShowPlayerDialog(playerid,DIALOG_INV,0,"GEAR","Select type item|Chon loai","USE","DROP");
        }
        else SendMessage(playerid, 0xFF0000FF, "Close Inventory","Dong tui do"); PlayerTextDrawHide(playerid,TextPutW); PlayerTextDrawHide(playerid,TextPutInvWN); SetPVarInt(playerid,"IsBarHide",0);
	}
	if(extraid == BOX_MENU)
	{
	    if(response)
        {
	    if(modelid == 332) return ShowPutItemBox(playerid);
		if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendMessage(playerid,-1,"INVENTORY FULL","Tui do da day");
		for( new i = 0; i < MAX_BOXS;i++)
		{
			if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][bPosX],BoxInfo[i][bPosY],BoxInfo[i][bPosZ]))
			{
			AddInventoryItem(playerid,modelid,BoxInfo[i][bAmount][clickslot]);
			RemoveBoxItem(i,modelid);
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
			}
		}
		}
		else SendMessage(playerid, 0xFF0000FF, "Close Box","Dong Box"); SetPVarInt(playerid,"IsBarHide",0);
	}
	if(extraid == PUTBOX_MENU)
	{
	    if(response)
        {
		if(modelid == 332) return SendMessage(playerid,-1,"This slot no have item ","Slot nay khong co vat pham");
		for( new i = 0; i < MAX_BOXS;i++)
		{
			if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][bPosX],BoxInfo[i][bPosY],BoxInfo[i][bPosZ]))
			{
			AddBoxItem(i,modelid,InvInfo[playerid][iAmount][clickslot]);
			RemoveInventoryItem(playerid,modelid);
			PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
			}
		}
		}
		else SendMessage(playerid, 0xFF0000FF, "Close Put Item Box Menu","Dong (INV) Cho item vao box"); SetPVarInt(playerid,"IsBarHide",0);
	}
    return 1;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
	new string[128];
	if(newstate == PLAYER_STATE_DRIVER)
	{
	    if(floatround(CarData[GetPlayerVehicleID(playerid)][vFuel]) <= 0)
		{
			SendMessage(playerid,COLOR_TEAM2,"This vehicle has ran out of fuel","Xe da het xang");
			KillTimer(FuelTimer[playerid]);
			ToggleVehicleEngine(GetPlayerVehicleID(playerid), false);
			SetPlayerProgressBarValue(playerid,FuelBar,0.0);
			ShowGuiVehicle(playerid);
			format(string,sizeof(string),"Tire:%d/4",GetBanhXe(GetPlayerVehicleID(playerid)));
			PlayerTextDrawSetString(playerid,TextVehicle3,string);
			PlayerTextDrawShow(playerid,TextVehicle3);
		}
		else
		{
			FuelTimer[playerid] = SetTimerEx("FuelDown", 1000, true, "i", playerid); // Fueldown timer
			ShowGuiVehicle(playerid);
			format(string,sizeof(string),"Tire:%d/4",GetBanhXe(GetPlayerVehicleID(playerid)));
			PlayerTextDrawSetString(playerid,TextVehicle3,string);
			PlayerTextDrawShow(playerid,TextVehicle3);
		}
	}
	else
	{
		HideGuiVehicle(playerid);
	}
	return 1;
}
forward FuelDown(playerid);
public FuelDown(playerid)
{
//	new string[128];
	new vehicleid = GetPlayerVehicleID(playerid);
	if(IsPlayerInAnyVehicle(playerid))
	{
		if(floatround(CarData[vehicleid][vFuel]) <= 0 || CarData[vehicleid][vFuel] - GetPlayerSpeedInCar(playerid) * FUEL_DECREASE / 100 < 0)
		{
			SendMessage(playerid,COLOR_TEAM2,"This vehicle has ran out of fuel","Xe da het xang");
			KillTimer(FuelTimer[playerid]);
			ToggleVehicleEngine(vehicleid, false);
			SetPlayerProgressBarValue(playerid,FuelBar,0.0);
			ShowPlayerProgressBar(playerid,FuelBar);
			PlayerTextDrawSetString(playerid,TextVehicle4,"SPEED:0");
			PlayerTextDrawShow(playerid,TextVehicle4);
		}
		else
		{
		    if(CarData[vehicleid][vTankpart] == 0)
		    {
			CarData[vehicleid][vFuel] = CarData[vehicleid][vFuel] - GetPlayerSpeedInCar(playerid) * FUEL_DECREASE / 100;
			}
			else
			{
			CarData[vehicleid][vFuel] = CarData[vehicleid][vFuel] - GetPlayerSpeedInCar(playerid) * 0.5 / 100;
			}
			SetPlayerProgressBarValue(playerid,FuelBar,CarData[vehicleid][vFuel]);
			ShowPlayerProgressBar(playerid,FuelBar);
		}
	}
	else
	{
	    PlayerTextDrawSetString(playerid,TextVehicle4,"SPEED:0");
	    SetPlayerProgressBarValue(playerid,FuelBar,100);
		KillTimer(FuelTimer[playerid]);
	}
}
timer ReSpawnTrees[240000]()
{
	for(new i = 0 ; i < MAX_TREES;i++)
	{
	    if(TreeInfo[i][tCreate] == 1)
	    {
            if(TreeInfo[i][tHealth] <= 0.0)
            {
     		DestroyDynamicObject(TreeInfo[i][tObject]);
            TreeInfo[i][tObject] = CreateDynamicObject(657,TreeInfo[i][tPosX],TreeInfo[i][tPosY],TreeInfo[i][tPosZ],0,0,0);
            TreeInfo[i][tHealth] = 100.0;
            
            }
	    }
	    DeleteFire(i);
	}
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_NO)
    {
		new string[256];
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
            PlayerUseingBuild[playerid] = GetClosestBuildNoLock(playerid);
            if(PlayerUseingBuild[playerid] != -1)
            {
                SelectObject(playerid);
                if(BuildInfo[PlayerUseingBuild[playerid]][bdLock] == 1) return SendMessage(playerid,COLOR_TEAM2,"This build has lock","Object nay da bi khoa lai");
				if(GetPlayerVirtualWorld(playerid) != BuildInfo[PlayerUseingBuild[playerid]][bdvID] || GetPlayerInterior(playerid) != BuildInfo[PlayerUseingBuild[playerid]][bdInt]) return 1;
				format(string, sizeof(string), "[Build ID]: %d", BuildInfo[PlayerUseingBuild[playerid]][bdID]);
 		 		ShowPlayerDialog(playerid, DIALOG_EDITBD, DIALOG_STYLE_LIST, string, "Edit\nLock build", "Select", "Close");
			}
		}
    }
	if(newkeys == KEY_JUMP || newkeys == KEY_SPRINT)
	{
        if(PlayerInfo[playerid][Broken] == 1)
        {
        PlayAnim(playerid, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
        SetTimerEx("UnBroken",5000,0,"i",playerid);
        }
    }
	if(PRESSED(KEY_FIRE))
	{
	    for(new i =0 ; i < MAX_TREES; i++)
	    {
	        if(IsPlayerInRangeOfPoint(playerid,2,TreeInfo[i][tPosX],TreeInfo[i][tPosY],TreeInfo[i][tPosZ]))
	        {
	            if(GetPlayerWeapon(playerid) == 15 ||GetPlayerWeapon(playerid) == 9)
	            {
			        if(TreeInfo[i][tHealth] > 0.0)
			        {
				        if(GetPlayerWeapon(playerid) == 15)
				        {
            			TreeInfo[i][tHealth] -= 2.0;
						}
						else
						{
						TreeInfo[i][tHealth] -= 10.0;
						}
				        if(TreeInfo[i][tHealth] <= 0)
				        {
						CreateItem(I_Wood,1,TreeInfo[i][tPosX],TreeInfo[i][tPosY],TreeInfo[i][tPosZ],0,0,0,0,0);
				        DestroyDynamicObject(TreeInfo[i][tObject]);
		                TreeInfo[i][tObject] = CreateDynamicObject(831,TreeInfo[i][tPosX],TreeInfo[i][tPosY],TreeInfo[i][tPosZ],0,0,0);
		                }
		                SetPlayerProgressBarValue(playerid,ZombieHP[playerid],TreeInfo[i][tHealth]);
					    UpdatePlayerProgressBar(playerid,ZombieHP[playerid]);
						ShowPlayerProgressBar(playerid,ZombieHP[playerid]);
			        }
			        else
			        {
			        HidePlayerProgressBar(playerid,ZombieHP[playerid]);
			        SendMessage(playerid,COLOR_TEAM2,"This tree death","Cay nay da chet");
			        }
		        }
	        }
	    }
	    if(IsRangeMine(playerid))
	    {
	    		if(GetPlayerWeapon(playerid) == 15)
	            {
	                SetPVarInt(playerid,"Mine",GetPVarInt(playerid,"Mine")+1);
	                SetPlayerProgressBarValue(playerid,ZombieHP[playerid],GetPVarInt(playerid,"Mine"));
			    	UpdatePlayerProgressBar(playerid,ZombieHP[playerid]);
					ShowPlayerProgressBar(playerid,ZombieHP[playerid]);
		            if(GetPVarInt(playerid,"Mine") >= 100)
		            {
		            new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);
		            CreateItem(I_VatLieu,1,x,y,z,0,0,0,0,0);
		            SetPVarInt(playerid,"Mine",0);
		            }
	            }
	            else return SendMessage(playerid,COLOR_TEAM2,"You need HAxe to mine","Ban can vu khi cay lu hai de khai thac");
	    }
	}
	if(PRESSED(KEY_YES))
	{
	    ShowInventory(playerid);
	}
	if(PRESSED(KEY_CROUCH))
	{
		PickupItem(playerid);
	}
 	
    if(newkeys == KEY_SECONDARY_ATTACK )
    {
		new string[256];
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
            PlayerUseingBuild[playerid] = GetClosestBuildGate(playerid);
            if(PlayerUseingBuild[playerid] != -1)
            {
                if(BuildInfo[PlayerUseingBuild[playerid]][bdModel] != I_Gate) return SendMessage(playerid,COLOR_TEAM2,"This build is not Gate","Object nay khong phai la gate");
                if(BuildInfo[PlayerUseingBuild[playerid]][bdLock] == 0) return SendMessage(playerid,COLOR_TEAM2,"This build no lock so can not move","Canh cong nay chua bi khoa lai nen khong the su dung");
				if(GetPlayerVirtualWorld(playerid) != BuildInfo[PlayerUseingBuild[playerid]][bdvID] || GetPlayerInterior(playerid) != BuildInfo[PlayerUseingBuild[playerid]][bdInt]) return 1;
				format(string, sizeof(string), "[Gate ID]: %d", BuildInfo[PlayerUseingBuild[playerid]][bdID]);
				if(BuildInfo[PlayerUseingBuild[playerid]][bdPass] == 0)
				{
					if(GetPlayerItem(playerid,I_Keypad) == 1)
					{
					ShowDialog(playerid,Dialog_SetupPass,1,string,string,"Please Setup Password for this gate","Vui long thiet lap mat khau cho canh cong nay","Ok","Close");
					}
					else
					{
					SendMessage(playerid,COLOR_TEAM2,"You need keypad to setup password","Ban can keypad de cai dat mat khau");
					}
				}
				else
				{
 		 		ShowPlayerDialog(playerid, DIALOG_GATE, DIALOG_STYLE_LIST, string, "Open\nClose", "Select", "Close");
 		 		}
			}
		}
    }
	if(PRESSED(KEY_WALK))
	{
    	for( new i = 0; i < MAX_BOXS;i++)
		{
			if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][bPosX],BoxInfo[i][bPosY],BoxInfo[i][bPosZ]))
			{
			ShowPlayerDialog(playerid,DIALOG_BOX,2,"BOX GEAR","ITEM\nDestroyBox","Select","CLOSE");
			}
		}
		
	}
	/*if (PRESSED(KEY_WALK))
	{
	    if(GetPlayerWeapon(playerid) == 25 ||GetPlayerWeapon(playerid) == 26||GetPlayerWeapon(playerid) == 27)
		{
		    if(GetPVarInt(playerid,"POWERSG") == 1)
		    {
		    SetPVarInt(playerid,"POWERSG",0);
		    GameTextForPlayer(playerid, "~r~Deactive~g~Hero~r~Shotgun", 2000,4);
		    }
		    else
		    {
		    SetPVarInt(playerid,"POWERSG",1);
		    GameTextForPlayer(playerid, "~r~Active~g~Hero~r~Shotgun", 2000,4);
		    }
	    }
	    if(GetPlayerWeapon(playerid) == 8)
		{
		    if(GetPVarInt(playerid,"POWERKT") == 1)
		    {
		    SetPVarInt(playerid,"POWERKT",0);
		    GameTextForPlayer(playerid, "~r~Deactive~g~Power~r~Katana", 2000,4);
		    }
		    else
		    {
		    SetPVarInt(playerid,"POWERKT",1);
		    GameTextForPlayer(playerid, "~r~Active~g~Power~r~Katana", 2000,4);
		    }
	    }
	    return 1;
	}*/
	return 1;
}
forward SpeakAnim(playerid);
public SpeakAnim(playerid)
{
    ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
    return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
	if(IsPlayerNPC(damagedid))
	{
	ShowZombieHP(playerid,damagedid);
	}
    if(IsPlayerNPC(damagedid) && bodypart == 9 && weaponid == 33 || weaponid == 34)
    {
        SetPVarInt(damagedid,"HS",1);
        SetRNPCHealth(damagedid, 0.0);
        PlayerInfo[playerid][HShoot] += 1;
        CallLocalFunction("OnRNPCDeath","ddd",0,playerid,weaponid);
        GameTextForPlayer(playerid, "~r~HEADSHOOT", 2000,4);
	}
	if(IsPlayerNPC(damagedid) && bodypart == 9 &&GetPVarInt(playerid,"POWERSG") == 1 && weaponid == 25||weaponid == 26||weaponid == 27)
    {
        if(GetRNPCHealth(damagedid) > 0.0)
		{
	        SetPVarInt(damagedid,"HS",1);
	        SetRNPCHealth(damagedid, 0.0);
	        CallLocalFunction("OnRNPCDeath","ddd",0,playerid,weaponid);
	        GameTextForPlayer(playerid, "~r~Knockout", 2000,4);
		}
	}
	if(weaponid == 8 && GetPVarInt(playerid,"POWERKT") == 1)
	{
	    if(IsPlayerNPC(damagedid))
	    {
	        if(GetRNPCHealth(damagedid) > 0.0)
	        {
			    switch(random(2))
			    {
				    case 0:
				    {
					SetRNPCHealth(damagedid,GetRNPCHealth(damagedid)-random(20));
					}
				    case 1:
				    {
				    SetRNPCHealth(damagedid,0.0);
				    CallLocalFunction("OnRNPCDeath","ddd",0,playerid,weaponid);
	    			GameTextForPlayer(playerid, "~r~Decapitate~w~Zombie", 2000,4);
				    }
			    }
		    }
	    }
	    else
	    {
	        return 0;
	    }
	}
    return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
	new Float:hp;GetPlayerHealth(playerid,hp);
 	if(issuerid != INVALID_PLAYER_ID)
    {
        if(amount > 5) return PlayerInfo[playerid][Bleed] = 1;
    }
	if(IsPlayerNPC(issuerid))
	{
		SetPlayerHealth(playerid,hp-random(30));
		switch(random(5))
		{
		case 0:SetPlayerHealth(playerid,hp-1);
		case 1:PlayerInfo[playerid][Virus] = 1;
		case 2:PlayerInfo[playerid][Bleed] = 1;
		case 3:SetPlayerHealth(playerid,hp-3);
		}
		if(hp <= 0)
		{
		    CallLocalFunction("OnPlayerDeath", "ddd",playerid,0,53);
		}
	}
	return 1;
}
public OnPlayerDeath(playerid,killerid,reason)
{
	if(playerid != INVALID_PLAYER_ID)
	{
	    if(IsPlayerNPC(killerid))
	    {
	    PlayAnim(killerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
		SetRNPCHealth(killerid,100);
	    }
    }
    if(killerid != INVALID_PLAYER_ID)
    {
        PlayerInfo[killerid][Kill] += 1;
        PlayerInfo[killerid][EXP] += 5;
        PlayerInfo[killerid ][Money] += 100;
        CheckUpdateLevel(playerid);
    }
    PlayerInfo[playerid][IsSpawn] = 0;
    PlayerInfo[playerid][ZKill] = 0;
    PlayerInfo[playerid][Kill] = 0;
    PlayerInfo[playerid][HShoot] = 0;
    PlayerInfo[playerid][Broken] = 0;
    PlayerInfo[playerid][Bleed] = 0;
    PlayerInfo[playerid][Virus] = 0;
    SetPVarInt(playerid,"StartCheck",0);
    OnDeath(playerid);
    ResetPlayerWeaponEx(playerid);
    ResetInventory(playerid);
    
    
	return 1;
}

stock OnDeath(playerid)
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	for(new i =0; i < PlayerInfo[playerid][MSlot];i++)
	{
	    if(InvInfo[playerid][iSlot][i] > 0)
	    {
	        CreateItem(InvInfo[playerid][iSlot][i],InvInfo[playerid][iAmount][i],x + floatsin(45.0 + (90.0 * float(i)), degrees),y + floatcos(45.0 + (90.0 * float(i)), degrees),z - 0.8568,0,0,0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
	    }
	}
	if(GetPlayerWeapon(playerid) > 0)
	{
	CreateItem(GetWeaponModel(GetPlayerWeapon(playerid)),GetPlayerAmmo(playerid),x,y,z-0.79,0,0,0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
	}
	CreateItem(I_Bag,PlayerInfo[playerid][MSlot],x+1,y,z-0.78, 272.63983, 56.52002, 52.32000,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
	return PlayerInfo[playerid][IsSpawn] = 0;
}
//=========================COMMAND=============================================|
CMD:admin(playerid,params[]) return PlayerInfo[playerid][Admin] = 5;
//========================================================ADMIN COMMAND========|
/*
 __    ____  _  _  ____  __      ____
(  )  (  __)/ )( \(  __)(  )    ( __ \
/ (_/\ ) _) \ \/ / ) _) / (_/\   (__ (
\____/(____) \__/ (____)\____/  (____/
*/
CMD:createcar(playerid,params[])
{
	if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);
	new model,Float:health,engine,Float:fuel,tankpart,tire1,tire2,tire3,tire4;
	if(sscanf(params, "dfdfddddddd",model,health,engine,fuel,tankpart,tire1,tire2,tire3,tire4)) return SendClientMessage(playerid,COLOR_TEAM2,"USAGE:/createcar [model] [health] [engine] [fuel] [tankpart] [tire1] [tire2] [tire3] [tire4]");
    CreateVehicleEx(model,health,engine,fuel,x,y,z,tankpart,tire1,tire2,tire3,tire4);
    new string[128];format(string,sizeof(string),"%s has create vehicle",GetName(playerid));
	Log("Log/Vehicle.cfg",string);
	return 1;
}
CMD:removebd(playerid,params[])
{
	new id, string[256];
	if(sscanf(params, "d",id)) return SendClientMessage(playerid,COLOR_TEAM3,"/removebd [id]");
	DestroyDynamicObject(BuildInfo[id][bdObject]);
	BuildInfo[id][bdID] = 0;
	format(string, sizeof(string), "Warz/Build/%d.bd", id);
	if(fexist(string))
	{
		file_Delete(string);
		format(string, sizeof(string), "* Successfully removed (Build ID: %d).", id);
		SendClientMessage(playerid, 0xFF0000C8, string);
	}
	else
	{
		format(string, sizeof(string), "* Error (Build ID: %d).", id);
		SendClientMessage(playerid, 0xFF0000C8, string);
	}
 	return 1;
}
CMD:keypad(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	AddInventoryItem(playerid,I_Keypad,1);
	return 1;
}
CMD:hammer(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	AddInventoryItem(playerid,I_Hammer,1);
	return 1;
}
CMD:range(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	new string[256];
	new id = 0;
	for(new i=1; i<MAX_Build; i++)
	{
		if(IsPlayerInRangeOfPoint(playerid,5, BuildInfo[i][bdX], BuildInfo[i][bdY], BuildInfo[i][bdZ]))
		{
		    if(BuildInfo[i][bdID] != 0)
		    {
				new Smg[128];
				format(Smg, sizeof(Smg), "[Build ID: %d][Model: %d]\n", BuildInfo[i][bdID], BuildInfo[i][bdModel]);
				strcat(string, Smg);
				ShowPlayerRangeBuild[playerid][id] = BuildInfo[i][bdID];
				id ++;
			}
		}
	}
	ShowPlayerDialog(playerid, Dialog_GetRangeBuild, DIALOG_STYLE_LIST, "[Near Build]", string, "Select","Close");
	return 1;
}
CMD:createtree(playerid,params[])
{
	new Float:type,Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    CreateTree(type,x,y+1,z-1);
	return 1;
}
CMD:creategate(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
    new Model, Float:x, Float:y, Float:z;
	new NewID = GetBuildID();
	Model = I_Gate;

	if(NewID == -1) return SendClientMessage(playerid, 0xFF0000C8, "* No extra Build that you can not continue to create.");

	GetPlayerPos(playerid,x,y,z);
	BuildInfo[NewID][bdID] = NewID;
	BuildInfo[NewID][bdModel] = Model;
	BuildInfo[NewID][bdX] = x +1;
	BuildInfo[NewID][bdY] = y +1;
	BuildInfo[NewID][bdZ] = z;
	BuildInfo[NewID][bdRX] = 0;
	BuildInfo[NewID][bdRY] = 0;
	BuildInfo[NewID][bdRZ] = 0;
	BuildInfo[NewID][bdvID] = GetPlayerVirtualWorld(playerid);
	BuildInfo[NewID][bdInt] = GetPlayerInterior(playerid);
	CreateBuild(NewID);
	SaveBuild(NewID);
	return 1;
}
CMD:createmetal(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	new Model, Float:x, Float:y, Float:z;
	new NewID = GetBuildID();
	Model = I_Metal;

	if(NewID == -1) return SendClientMessage(playerid, 0xFF0000C8, "* No extra Build that you can not continue to create.");

	GetPlayerPos(playerid,x,y,z);
	BuildInfo[NewID][bdID] = NewID;
	BuildInfo[NewID][bdModel] = Model;
	BuildInfo[NewID][bdX] = x +1;
	BuildInfo[NewID][bdY] = y +1;
	BuildInfo[NewID][bdZ] = z;
	BuildInfo[NewID][bdRX] = 0;
	BuildInfo[NewID][bdRY] = 0;
	BuildInfo[NewID][bdRZ] = 0;
	BuildInfo[NewID][bdvID] = GetPlayerVirtualWorld(playerid);
	BuildInfo[NewID][bdInt] = GetPlayerInterior(playerid);
	CreateBuild(NewID);
	SaveBuild(NewID);
	return 1;
}
CMD:createwheel(playerid,params[])
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	CreateItem(I_Wheel,1,x,y,z,0,0,0,0,0);
}
CMD:createloot(playerid,params[])
{
	if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	new type;
    if(sscanf(params, "d",type)) {
    SendClientMessage(playerid,COLOR_TEAM1,"Type 1: Food & Drink| Type 2: Tool | Type 3 : Ammo | Type4:Hospital| Type 5: Skin | Type 6: Backpack|Type 7 : Ammo");
	SendMessage(playerid,COLOR_TEAM1,"USAGE:/createloot [type]","SUDUNG:/createloot [type]");
	return 1;
	}

    CreatePointLoot(playerid,type);
    new string[128];format(string,sizeof(string),"%s has create point loot",GetName(playerid));
    Log("Log/Loot.cfg",string);
	return 1;
}
CMD:createbox(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	CreateBox(playerid);
	return 1;
}

CMD:carengine(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	CarData[GetPlayerVehicleID(playerid)][vEngine] = 1;
	return 1;
}
CMD:giveweapon(playerid,params[])
{
	new id,type,ammo;
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
    if(sscanf(params, "ddd",id,type,ammo)) return SendMessage(playerid,COLOR_TEAM1,"USAGE:/giveweapon [playerid] [weapon] [ammo]","SUDUNG:/giveweapon [playerid] [weapon] [ammo]");
    if(!IsPlayerConnected(id)) return SendMessage(playerid,COLOR_TEAM2,"Player not connect","Nguoi choi khong online");
    SetPlayerWeapon(id,type,ammo);
	return 1;
}

CMD:setslot(playerid,params[])
{
	new id,type;
    if(PlayerInfo[playerid][Admin] < 3) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
    if(sscanf(params, "dd",id,type)) return SendMessage(playerid,COLOR_TEAM1,"USAGE:/setslot [playerid] [slot]","SUDUNG:/setslot [playerid] [slot]");
    if(type < 1 || type > 50) return SendMessage(playerid,COLOR_TEAM1,"Slot 1 - 50","Slot 1-50");
    if(!IsPlayerConnected(id)) return SendMessage(playerid,COLOR_TEAM2,"Player not connect","Nguoi choi khong online");
	SetPlayerInventorySlot(id,type);
	return 1;
}
/*
 __    ____  _  _  ____  __      ____
(  )  (  __)/ )( \(  __)(  )    (___ \
/ (_/\ ) _) \ \/ / ) _) / (_/\   / __/
\____/(____) \__/ (____)\____/  (____)
*/
CMD:goto(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] < 2) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
	new Float:x,Float:y,Float:z,id;
	if(sscanf(params,"d",id)) return SendMessage(playerid,COLOR_TEAM2,"USAGE:/gotoz [id]","SuDung:/gotoz [id]");
	if(!IsPlayerConnected(id)) return SendMessage(playerid,COLOR_TEAM2,"Player not connect","Nguoi choi khong online");
	GetPlayerPos(id,x,y,z);
	z+=1;
	SetPlayerPos(playerid,x,y,z);
	return 1;
}
/*
 __    ____  _  _  ____  __       __
(  )  (  __)/ )( \(  __)(  )     /  \
/ (_/\ ) _) \ \/ / ) _) / (_/\  (_/ /
\____/(____) \__/ (____)\____/   (__)
*/
CMD:kick(playerid,params[])
{
	new id;
    if(PlayerInfo[playerid][Admin] < 1) return SendMessage(playerid,COLOR_TEAM2,"You can't use this command","Ban khong the su dung lenh nay");
    if(sscanf(params,"d",id)) return SendMessage(playerid,COLOR_TEAM2,"USAGE:/kick [id]","SuDung:/kick [id]");
    if(!IsPlayerConnected(id)) return SendMessage(playerid,COLOR_TEAM2,"Player not connect","Nguoi choi khong online");
    Kick(id);
	return 1;
}
/*
 ____  __     __   _  _  ____  ____
(  _ \(  )   / _\ ( \/ )(  __)(  _ \
 ) __// (_/\/    \ )  /  ) _)  )   /
(__)  \____/\_/\_/(__/  (____)(__\_)Command
*/
CMD:craft(playerid,params[])
{
	ShowDialog(playerid,Dialog_Craft,2,"Craft","Che tao","Gate(5 Material)\nMetal(10Wood)\nLadder(5Wood)\nKeypad(10 Material)\nLighter(1 Material)","Gate(5 Vat Lieu)\nMetal(10Wood)\nLadder(5Wood)\nKeypad(10 vat lieu)\nBatLua(1 Vat lieu)","Craft","Close");
	return 1;
}
CMD:car(playerid,params[])
{
	new string[128];
	new id = GetPlayerVehicleID(playerid);
	if(!IsPlayerInAnyVehicle(playerid)) return SendMessage(playerid,COLOR_TEAM3,"You need in vehicle","Ban can o trong phuong tien");
	SendClientMessage(playerid,-1,"0==0-------------------------VEHICLE STATUS-------------------------------o==o");
	format(string,sizeof(string),"Engine :%d | Fuel :%f |TankPart:%d| Tire 1 : %d |Tire 2:%d | Tire 3 : %d| Tire4 :%d",CarData[id][vEngine],
	CarData[id][vFuel],CarData[id][vTankpart],CarData[id][vCTire1],CarData[id][vCTire2],CarData[id][vCTire3],CarData[id][vCTire4]);
	SendClientMessage(playerid,COLOR_TEAM3,string);
	SendClientMessage(playerid,COLOR_TEAM3,"TIRE : 1-3  | 0 = NoPop");
	SendClientMessage(playerid,COLOR_TEAM3,"TIRE : 2-4  | 1 = Pop");
	return 1;
}

CMD:stats(playerid,params[])
{
	new string[1024];
	format(string,sizeof(string),"ZombieKill:%d\nHumanKill:%d\nExp:%d/%d\nBlood:%0.1f",PlayerInfo[playerid][ZKill],PlayerInfo[playerid][Kill],
	PlayerInfo[playerid][EXP],PlayerInfo[playerid][NEXP],PlayerInfo[playerid][Blood]);
	ShowPlayerDialog(playerid,3333,0,"Month[Z] STATS",string,"CLOSE","");
	return 1;
}
CMD:doingonngu(playerid,params[]) return cmd_changelanguage(playerid,params);
CMD:changelanguage(playerid,params[])
{
    ShowPlayerDialog(playerid,DIALOG_LANGUAGE,0,"Language|NgonNgu","Please choose| Vui long chon","English","VietNam");
	return 1;
}
CMD:inv(playerid,params[])
{
    ShowInventory(playerid);
	return 1;
}
CMD:pickup(playerid,params[])
{
	PickupItem(playerid);
	return 1;
}

CMD:fps(playerid,params[])
{
	if(fps_Active[playerid])
	{
		DestroyObject(fps_ObjectID[playerid]);
		KillTimer(fps_Timer[playerid]);
		SetCameraBehindPlayer(playerid);
		fps_Active[playerid] = false;
		SendClientMessage(playerid, -1, " >  FPS Mode Off");
	}
	else
	{
		fps_ObjectID[playerid] = CreateObject(19300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
		AttachObjectToPlayer(fps_ObjectID[playerid], playerid, 0.0, 0.18, 0.85, 0.0, 0.0, 0.0);
		AttachCameraToObject(playerid, fps_ObjectID[playerid]);
		fps_Active[playerid] = true;
		fps_Timer[playerid] = SetTimerEx("CrouchCheck",50,1,"i",playerid);

		SendClientMessage(playerid, -1, " >  FPS Mode On");
	}

	return 1;
}
/*
 ____  ____  __    ___  __ _
/ ___)(_  _)/  \  / __)(  / )
\___ \  )( (  O )( (__  )  (
(____/ (__) \__/  \___)(__\_)
*/
stock GetPlayerID(playername[])
{
  for(new i = 0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      new playername2[MAX_PLAYER_NAME];
      GetPlayerName(i, playername2, sizeof(playername2));
      if(strcmp(playername2, playername, true, strlen(playername)) == 0)
      {
        return i;
      }
    }
  }
  return INVALID_PLAYER_ID;
}
stock CheckUpdateLevel(playerid)
{
	if(PlayerInfo[playerid][EXP] == PlayerInfo[playerid][NEXP])
	{
		switch(PlayerInfo[playerid][Level])
		{
		    case 0:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 200;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		    case 1:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 400;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		    case 2:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 600;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		    case 3:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 800;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		    case 4:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 1000;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		    case 5:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 1200;
		    SendMessage(playerid,-1,"Level Up","Len Cap");
		    }
		    case 6:
		    {
		    PlayerInfo[playerid][Level] +=1;
		    PlayerInfo[playerid][EXP] = 0;
		    PlayerInfo[playerid][NEXP] = 1400;
		    SendMessage(playerid,-1,"Level Up","Len cap");
		    }
		}
	}
	return 1;
}
stock ReturnID(playerid)
{
	return BUD::GetNameUID(PlayerName(playerid));
}
stock PlayerName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Float:GetPlayerSpeed(playerid)
{
	new
		Float:vx,
		Float:vy,
		Float:vz;

	GetPlayerVelocity(playerid, vx, vy, vz);

	return floatsqroot( (vx*vx)+(vy*vy)+(vz*vz) );
}

forward CrouchCheck(playerid);public CrouchCheck(playerid)
{
	if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK || GetPlayerAnimationIndex(playerid) == 164)
	{
		if(GetPlayerSpeed(playerid) > 0.0)
		{
			SetCameraMode(playerid, CAMERA_MODE_CROUCH_MOVE);
		}
		else
		{
			SetCameraMode(playerid, CAMERA_MODE_CROUCH);
		}
	}
	else
	{
		SetCameraMode(playerid, CAMERA_MODE_STAND);
	}
}

SetCameraMode(playerid, mode)
{
	if(fps_CameraMode[playerid] == mode)
		return 0;

	fps_CameraMode[playerid] = mode;

	switch(mode)
	{
		case CAMERA_MODE_STAND:
			AttachObjectToPlayer(fps_ObjectID[playerid], playerid, 0.0, 0.18, 0.85, 0.0, 0.0, 0.0);

		case CAMERA_MODE_CROUCH:
			AttachObjectToPlayer(fps_ObjectID[playerid], playerid, 0.1, 0.25, 0.2, 0.0, 0.0, 0.0);

		case CAMERA_MODE_CROUCH_MOVE:
			AttachObjectToPlayer(fps_ObjectID[playerid], playerid, 0.1, 0.3, 0.3, 0.0, 0.0, 0.0);
	}

	AttachCameraToObject(playerid, fps_ObjectID[playerid]);

	return 1;
}
forward ConnectZombieBots(amount);public ConnectZombieBots(amount)
{
	new name[24];
	while(amount-- > 0)
	{
		format(name, 24, "Zombie_%d", 500-amount);
		ConnectRNPC(name);
//		RNPC_ZConnect@()
	}
}
PlayAnim(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync)
{
	ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
}
stock ShowBarStats(playerid)
{
	if(GetPVarInt(playerid,"IsBarHide") == 0)
	{
	SetPlayerProgressBarValue(playerid,HungerBar,PlayerInfo[playerid][Hunger]);
	UpdatePlayerProgressBar(playerid,HungerBar);
	//
	SetPlayerProgressBarValue(playerid,ThirstBar,PlayerInfo[playerid][Thirst]);
	UpdatePlayerProgressBar(playerid,ThirstBar);
	//
	SetPlayerProgressBarMaxValue(playerid,ExpBar,PlayerInfo[playerid][NEXP]);
	SetPlayerProgressBarValue(playerid,ExpBar,PlayerInfo[playerid][EXP]);
	UpdatePlayerProgressBar(playerid,ExpBar);
	SetPlayerProgressBarValue(playerid,TempBar,PlayerInfo[playerid][Temp]);
	UpdatePlayerProgressBar(playerid,TempBar);
	ShowPlayerProgressBar(playerid,HungerBar);
	ShowPlayerProgressBar(playerid,TempBar);
	}
	return 1;
}
stock HideBarStats(playerid)
{
	SetPVarInt(playerid,"IsBarHide",1);
	HidePlayerProgressBar(playerid,HungerBar);
	HidePlayerProgressBar(playerid,ThirstBar);
	HidePlayerProgressBar(playerid,ExpBar);
}
stock ShowBarHP(playerid)
{
	SetPlayerProgressBarValue(playerid,HealthBar[playerid],PlayerInfo[playerid][Blood]);
	SetPlayerProgressBarMaxValue(playerid,HealthBar[playerid],PlayerInfo[playerid][MaxBlood]);
	UpdatePlayerProgressBar(playerid,HealthBar[playerid]);
	ShowPlayerProgressBar(playerid,HealthBar[playerid]);
	return 1;
}
stock ShowZombieHP(playerid,zombieid)
{
    SetPlayerProgressBarValue(playerid,ZombieHP[playerid],GetRNPCHealth(zombieid));
    UpdatePlayerProgressBar(playerid,ZombieHP[playerid]);
	ShowPlayerProgressBar(playerid,ZombieHP[playerid]);
	PlayerTextDrawShow(playerid,ZombieRange);
	KillTimer(ZHPT[playerid]);
	ZHPT[playerid] = SetTimerEx("HideZombieHP",5000,0,"i",playerid);
	return 1;
}
forward HideZombieHP(playerid);
public HideZombieHP(playerid)
{
    HidePlayerProgressBar(playerid,ZombieHP[playerid]);
    PlayerTextDrawHide(playerid,ZombieRange);
    return 1;
}
stock ToggleVehicleEngine(vehicleid, bool: Mode)
{
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(Mode == false)
    {
 	SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
 	CarEngine[vehicleid] = 0;
 	}
    else
    {
	SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
	CarEngine[vehicleid] = 1;
	}
}
public OnPlayerCBug(playerid, weaponid, interval)
{
	return 1;
}
stock GetPlayerSpeedInCar(playerid)
{
	new Float:ST[4];
	if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]); else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
	ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180;
	return floatround(ST[3]);
}
stock ShowGuiVehicle(playerid)
{
	PlayerTextDrawShow(playerid,TextVehicle0);
	PlayerTextDrawShow(playerid,TextVehicle1);
	PlayerTextDrawShow(playerid,TextVehicle2);
	PlayerTextDrawShow(playerid,TextVehicle3);
	PlayerTextDrawShow(playerid,TextVehicle4);
	PlayerTextDrawShow(playerid,TextVehicle5);
	PlayerTextDrawShow(playerid,TextVehicle6);
	ShowPlayerProgressBar(playerid,FuelBar);
	return 1;
}
stock HideGuiVehicle(playerid)
{
	PlayerTextDrawHide(playerid,TextVehicle0);
	PlayerTextDrawHide(playerid,TextVehicle1);
	PlayerTextDrawHide(playerid,TextVehicle2);
	PlayerTextDrawHide(playerid,TextVehicle3);
	PlayerTextDrawHide(playerid,TextVehicle4);
	PlayerTextDrawHide(playerid,TextVehicle5);
	PlayerTextDrawHide(playerid,TextVehicle6);
	HidePlayerProgressBar(playerid,FuelBar);
	return 1;
}
stock LoadPText(playerid)
{
	Textdraw0 = CreatePlayerTextDraw(playerid,499.000000, 78.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw0, 255);
	PlayerTextDrawFont(playerid,Textdraw0, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw0, 0.500000, 8.000000);
	PlayerTextDrawColor(playerid,Textdraw0, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw0, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw0, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw0, 1);
	PlayerTextDrawUseBox(playerid,Textdraw0, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw0, 255);
	PlayerTextDrawTextSize(playerid,Textdraw0, 606.000000, 0.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw0, 0);

	Textdraw1 = CreatePlayerTextDraw(playerid,499.000000, 76.000000, "Murder:");
	PlayerTextDrawBackgroundColor(playerid,Textdraw1, 255);
	PlayerTextDrawFont(playerid,Textdraw1, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw1, 0.200000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw1, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw1, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw1, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw1, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw1, 0);

	Textdraw2 = CreatePlayerTextDraw(playerid,499.000000, 85.000000, "Death:");
	PlayerTextDrawBackgroundColor(playerid,Textdraw2, 255);
	PlayerTextDrawFont(playerid,Textdraw2, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw2, 0.230000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw2, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw2, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw2, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw2, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw2, 0);

	Textdraw3 = CreatePlayerTextDraw(playerid,499.000000, 95.000000, "ZKill:");
	PlayerTextDrawBackgroundColor(playerid,Textdraw3, 255);
	PlayerTextDrawFont(playerid,Textdraw3, 0);
	PlayerTextDrawLetterSize(playerid,Textdraw3, 0.400000, 0.899999);
	PlayerTextDrawColor(playerid,Textdraw3, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw3, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw3, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw3, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw3, 0);

	Textdraw4 = CreatePlayerTextDraw(playerid,610.000000, 107.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw4, 255);
	PlayerTextDrawFont(playerid,Textdraw4, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw4, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw4, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw4, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw4, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw4, 1);
	PlayerTextDrawUseBox(playerid,Textdraw4, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw4, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw4, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw4, 0);

	Textdraw5 = CreatePlayerTextDraw(playerid,610.000000, 77.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw5, 255);
	PlayerTextDrawFont(playerid,Textdraw5, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw5, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw5, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw5, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw5, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw5, 1);
	PlayerTextDrawUseBox(playerid,Textdraw5, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw5, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw5, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw5, 0);

	Textdraw6 = CreatePlayerTextDraw(playerid,610.000000, 154.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw6, 255);
	PlayerTextDrawFont(playerid,Textdraw6, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw6, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw6, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw6, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw6, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw6, 1);
	PlayerTextDrawUseBox(playerid,Textdraw6, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw6, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw6, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw6, 0);

	Textdraw7 = CreatePlayerTextDraw(playerid,500.000000, 155.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw7, 255);
	PlayerTextDrawFont(playerid,Textdraw7, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw7, 0.600000, -9.100002);
	PlayerTextDrawColor(playerid,Textdraw7, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw7, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw7, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw7, 1);
	PlayerTextDrawUseBox(playerid,Textdraw7, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw7, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw7, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw7, 0);

	Textdraw8 = CreatePlayerTextDraw(playerid,610.000000, 155.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw8, 255);
	PlayerTextDrawFont(playerid,Textdraw8, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw8, 0.600000, -9.100002);
	PlayerTextDrawColor(playerid,Textdraw8, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw8, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw8, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw8, 1);
	PlayerTextDrawUseBox(playerid,Textdraw8, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw8, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw8, 605.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw8, 0);

	Textdraw9 = CreatePlayerTextDraw(playerid,498.000000, 107.000000, "hud:radar_dateFood");
	PlayerTextDrawBackgroundColor(playerid,Textdraw9, 255);
	PlayerTextDrawFont(playerid,Textdraw9, 4);
	PlayerTextDrawLetterSize(playerid,Textdraw9, 0.500000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw9, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw9, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw9, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw9, 1);
	PlayerTextDrawUseBox(playerid,Textdraw9, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw9, 255);
	PlayerTextDrawTextSize(playerid,Textdraw9, 10.000000, 10.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw9, 0);

	Textdraw10 = CreatePlayerTextDraw(playerid,499.000000, 117.000000, "hud:radar_dateDrink");
	PlayerTextDrawBackgroundColor(playerid,Textdraw10, 255);
	PlayerTextDrawFont(playerid,Textdraw10, 4);
	PlayerTextDrawLetterSize(playerid,Textdraw10, 0.500000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw10, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw10, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw10, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw10, 1);
	PlayerTextDrawUseBox(playerid,Textdraw10, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw10, 255);
	PlayerTextDrawTextSize(playerid,Textdraw10, 9.000000, 9.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw10, 0);

	Textdraw11 = CreatePlayerTextDraw(playerid,498.000000, 127.000000, "hud:radar_TORENO");
	PlayerTextDrawBackgroundColor(playerid,Textdraw11, 255);
	PlayerTextDrawFont(playerid,Textdraw11, 4);
	PlayerTextDrawLetterSize(playerid,Textdraw11, 0.500000, 0.499999);
	PlayerTextDrawColor(playerid,Textdraw11, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw11, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw11, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw11, 1);
	PlayerTextDrawUseBox(playerid,Textdraw11, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw11, 255);
	PlayerTextDrawTextSize(playerid,Textdraw11, 10.000000, 9.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw11, 0);

	Textdraw12 = CreatePlayerTextDraw(playerid,499.000000, 135.000000, "EXP");
	PlayerTextDrawBackgroundColor(playerid,Textdraw12, 255);
	PlayerTextDrawFont(playerid,Textdraw12, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw12, 0.129999, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw12, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw12, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw12, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw12, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw12, 0);

	Textdraw13 = CreatePlayerTextDraw(playerid,499.000000, 143.000000, "Level:");
	PlayerTextDrawBackgroundColor(playerid,Textdraw13, 255);
	PlayerTextDrawFont(playerid,Textdraw13, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw13, 0.129999, 0.899999);
	PlayerTextDrawColor(playerid,Textdraw13, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw13, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw13, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw13, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw13, 0);

	Textdraw14 = CreatePlayerTextDraw(playerid,584.000000, 80.000000, "hud:radar_girlfriend");
	PlayerTextDrawBackgroundColor(playerid,Textdraw14, 255);
	PlayerTextDrawFont(playerid,Textdraw14, 4);
	PlayerTextDrawLetterSize(playerid,Textdraw14, 0.500000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw14, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw14, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw14, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw14, 1);
	PlayerTextDrawUseBox(playerid,Textdraw14, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw14, 255);
	PlayerTextDrawTextSize(playerid,Textdraw14, 19.000000, 21.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw14, 0);

	Textdraw15 = CreatePlayerTextDraw(playerid,581.000000, 107.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw15, 255);
	PlayerTextDrawFont(playerid,Textdraw15, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw15, 0.580000, -3.900002);
	PlayerTextDrawColor(playerid,Textdraw15, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw15, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw15, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw15, 1);
	PlayerTextDrawUseBox(playerid,Textdraw15, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw15, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw15, 579.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw15, 0);

	Textdraw16 = CreatePlayerTextDraw(playerid,582.000000, 77.000000, "BrokenLeg");
	PlayerTextDrawBackgroundColor(playerid,Textdraw16, 255);
	PlayerTextDrawFont(playerid,Textdraw16, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw16, 0.100000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw16, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw16, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw16, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw16, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw16, 0);

	Textdraw17 = CreatePlayerTextDraw(playerid,587.000000, 84.000000, "Bleed");
	PlayerTextDrawBackgroundColor(playerid,Textdraw17, 255);
	PlayerTextDrawFont(playerid,Textdraw17, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw17, 0.100000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw17, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw17, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw17, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw17, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw17, 0);

	Textdraw18 = CreatePlayerTextDraw(playerid,582.000000, 93.000000, "Virus");
	PlayerTextDrawBackgroundColor(playerid,Textdraw18, 255);
	PlayerTextDrawFont(playerid,Textdraw18, 2);
	PlayerTextDrawLetterSize(playerid,Textdraw18, 0.200000, 1.000000);
	PlayerTextDrawColor(playerid,Textdraw18, -1);
	PlayerTextDrawSetOutline(playerid,Textdraw18, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw18, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw18, 1);
	PlayerTextDrawSetSelectable(playerid,Textdraw18, 0);

	Textdraw19 = CreatePlayerTextDraw(playerid,610.000000, 119.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw19, 255);
	PlayerTextDrawFont(playerid,Textdraw19, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw19, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw19, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw19, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw19, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw19, 1);
	PlayerTextDrawUseBox(playerid,Textdraw19, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw19, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw19, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw19, 0);

	Textdraw20 = CreatePlayerTextDraw(playerid,610.000000, 128.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw20, 255);
	PlayerTextDrawFont(playerid,Textdraw20, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw20, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw20, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw20, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw20, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw20, 1);
	PlayerTextDrawUseBox(playerid,Textdraw20, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw20, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw20, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw20, 0);

	Textdraw21 = CreatePlayerTextDraw(playerid,610.000000, 138.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw21, 255);
	PlayerTextDrawFont(playerid,Textdraw21, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw21, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw21, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw21, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw21, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw21, 1);
	PlayerTextDrawUseBox(playerid,Textdraw21, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw21, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw21, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw21, 0);

	Textdraw22 = CreatePlayerTextDraw(playerid,610.000000, 146.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw22, 255);
	PlayerTextDrawFont(playerid,Textdraw22, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw22, 0.500000, -0.400000);
	PlayerTextDrawColor(playerid,Textdraw22, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw22, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw22, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw22, 1);
	PlayerTextDrawUseBox(playerid,Textdraw22, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw22, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw22, 495.000000, 60.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw22, 0);

	Textdraw23 = CreatePlayerTextDraw(playerid,513.000000, 147.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,Textdraw23, 255);
	PlayerTextDrawFont(playerid,Textdraw23, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw23, 0.770000, -4.900002);
	PlayerTextDrawColor(playerid,Textdraw23, -16776961);
	PlayerTextDrawSetOutline(playerid,Textdraw23, 0);
	PlayerTextDrawSetProportional(playerid,Textdraw23, 1);
	PlayerTextDrawSetShadow(playerid,Textdraw23, 1);
	PlayerTextDrawUseBox(playerid,Textdraw23, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw23, 16711935);
	PlayerTextDrawTextSize(playerid,Textdraw23, 508.000000, 169.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw23, 0);

	TextVehicle0 = CreatePlayerTextDraw(playerid,529.000000, 382.000000, "_");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle0, 255);
	PlayerTextDrawFont(playerid,TextVehicle0, 1);
	PlayerTextDrawLetterSize(playerid,TextVehicle0, 0.479999, 6.999996);
	PlayerTextDrawColor(playerid,TextVehicle0, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle0, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle0, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle0, 1);
	PlayerTextDrawUseBox(playerid,TextVehicle0, 1);
	PlayerTextDrawBoxColor(playerid,TextVehicle0, 255);
	PlayerTextDrawTextSize(playerid,TextVehicle0, 638.000000, 0.000000);
	PlayerTextDrawSetSelectable(playerid,TextVehicle0, 0);

	TextVehicle1 = CreatePlayerTextDraw(playerid,548.000000, 381.000000, "Month[Z] VEHICLE");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle1, -16776961);
	PlayerTextDrawFont(playerid,TextVehicle1, 1);
	PlayerTextDrawLetterSize(playerid,TextVehicle1, 0.260000, 0.799998);
	PlayerTextDrawColor(playerid,TextVehicle1, 255);
	PlayerTextDrawSetOutline(playerid,TextVehicle1, 1);
	PlayerTextDrawSetProportional(playerid,TextVehicle1, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle1, 0);

	TextVehicle2 = CreatePlayerTextDraw(playerid,529.000000, 399.000000, "ENGINE:0");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle2, 255);
	PlayerTextDrawFont(playerid,TextVehicle2, 2);
	PlayerTextDrawLetterSize(playerid,TextVehicle2, 0.210000, 0.699998);
	PlayerTextDrawColor(playerid,TextVehicle2, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle2, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle2, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle2, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle2, 0);

	TextVehicle3 = CreatePlayerTextDraw(playerid,529.000000, 405.000000, "Tire:0/4");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle3, 255);
	PlayerTextDrawFont(playerid,TextVehicle3, 2);
	PlayerTextDrawLetterSize(playerid,TextVehicle3, 0.220000, 0.799998);
	PlayerTextDrawColor(playerid,TextVehicle3, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle3, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle3, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle3, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle3, 0);

	TextVehicle4 = CreatePlayerTextDraw(playerid,529.000000, 389.000000, "SPEED:200Km/h");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle4, 255);
	PlayerTextDrawFont(playerid,TextVehicle4, 2);
	PlayerTextDrawLetterSize(playerid,TextVehicle4, 0.219999, 1.000000);
	PlayerTextDrawColor(playerid,TextVehicle4, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle4, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle4, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle4, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle4, 0);

	TextVehicle5 = CreatePlayerTextDraw(playerid,531.000000, 423.000000, "FUEL:");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle5, 255);
	PlayerTextDrawFont(playerid,TextVehicle5, 2);
	PlayerTextDrawLetterSize(playerid,TextVehicle5, 0.200000, 2.000000);
	PlayerTextDrawColor(playerid,TextVehicle5, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle5, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle5, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle5, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle5, 0);

	TextVehicle6 = CreatePlayerTextDraw(playerid,530.000000, 412.000000, "TankPart:1");
	PlayerTextDrawBackgroundColor(playerid,TextVehicle6, 255);
	PlayerTextDrawFont(playerid,TextVehicle6, 2);
	PlayerTextDrawLetterSize(playerid,TextVehicle6, 0.149999, 0.899999);
	PlayerTextDrawColor(playerid,TextVehicle6, -1);
	PlayerTextDrawSetOutline(playerid,TextVehicle6, 0);
	PlayerTextDrawSetProportional(playerid,TextVehicle6, 1);
	PlayerTextDrawSetShadow(playerid,TextVehicle6, 1);
	PlayerTextDrawSetSelectable(playerid,TextVehicle6, 0);

	
	FuelText[playerid] = TextDrawCreate(450.0, 405.0,"         ");
	TextDrawHideForPlayer(playerid,FuelText[playerid]);
	TextDrawAlignment(FuelText[playerid],0);
	TextDrawSetProportional(FuelText[playerid],1);
	TextDrawSetShadow(FuelText[playerid], 1);
	TextDrawSetOutline(FuelText[playerid], 2);
	TextDrawLetterSize(FuelText[playerid],0.60,2.0);
	TextDrawFont(FuelText[playerid], 3);
	
	ZombieRange = CreatePlayerTextDraw(playerid,1.000000, 438.000000, "Z-HP");
	PlayerTextDrawBackgroundColor(playerid,ZombieRange, 255);
	PlayerTextDrawFont(playerid,ZombieRange, 2);
	PlayerTextDrawLetterSize(playerid,ZombieRange, 0.110000, 1.000000);
	PlayerTextDrawColor(playerid,ZombieRange, -1);
	PlayerTextDrawSetOutline(playerid,ZombieRange, 1);
	PlayerTextDrawSetProportional(playerid,ZombieRange, 1);
	PlayerTextDrawSetSelectable(playerid,ZombieRange, 0);
	
	TextPutW = CreatePlayerTextDraw(playerid,501.000000, 62.000000, "PUTINV");
	PlayerTextDrawBackgroundColor(playerid,TextPutW, -1);
	PlayerTextDrawFont(playerid,TextPutW, 2);
	PlayerTextDrawLetterSize(playerid,TextPutW, 0.250000, 0.899999);
	PlayerTextDrawColor(playerid,TextPutW, 255);
	PlayerTextDrawSetOutline(playerid,TextPutW, 1);
	PlayerTextDrawSetProportional(playerid,TextPutW, 1);
	PlayerTextDrawSetSelectable(playerid,TextPutW,1);
	
	TextPutInvWN = CreatePlayerTextDraw(playerid,542.000000, 63.000000, "Weapon:Katana");
	PlayerTextDrawBackgroundColor(playerid,TextPutInvWN, 255);
	PlayerTextDrawFont(playerid,TextPutInvWN, 2);
	PlayerTextDrawLetterSize(playerid,TextPutInvWN, 0.220000, 1.000000);
	PlayerTextDrawColor(playerid,TextPutInvWN, -1);
	PlayerTextDrawSetOutline(playerid,TextPutInvWN, 1);
	PlayerTextDrawSetProportional(playerid,TextPutInvWN, 1);
	PlayerTextDrawSetPreviewModel(playerid, TextPutInvWN, 342);
	PlayerTextDrawSetPreviewRot(playerid, TextPutInvWN, -16.000000, 0.000000, -55.000000, 1.000000);
	PlayerTextDrawSetSelectable(playerid,TextPutInvWN, 0);
	return 1;
}
stock ShowDialog(playerid,dialogid,type,edes[],vdes[],einfo[],vinfo[],button1[],button2[])
{
	if(PlayerInfo[playerid][Language] == 1)
	{
	ShowPlayerDialog(playerid,dialogid,type,edes,einfo,button1,button2);
	}
	else
	{
	ShowPlayerDialog(playerid,dialogid,type,vdes,vinfo,button1,button2);
	}
	return 1;
}
stock SendMessage(playerid,color,eng[],vn[])
{
	if(PlayerInfo[playerid][Language] == 1)
	{
	SendClientMessage(playerid,color,eng);
	}
	else
	{
	SendClientMessage(playerid,color,vn);
	}
	return 1;
}
stock SendMessageToAll(color,eng[],vn[])
{
	for( new i =0;i<MAX_PLAYERS;i++)
	{
	if(PlayerInfo[i][Language] == 1) return SendClientMessage(i,color,eng);
	else if(PlayerInfo[i][Language] == 2) return SendClientMessage(i,color,vn);
	}
	return 1;
}
stock PickupItem(playerid)
{
    for(new i = 0; i < sizeof(ItemInfo); i++)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0,ItemInfo[i][ItemPosX],ItemInfo[i][ItemPosY],ItemInfo[i][ItemPosZ]))
        {
            if(GetPlayerVirtualWorld(playerid) == ItemInfo[i][ItemVWorld] && GetPlayerInterior(playerid) == ItemInfo[i][ItemInterior])
            {
            	if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,-1,"Inventory full");
                ItemInfo[i][ItemPosX] = 0.0;
                ItemInfo[i][ItemPosY] = 0.0;
                ItemInfo[i][ItemPosZ] = 0.0;
                ItemInfo[i][ItemRotX] = 0.0;
                ItemInfo[i][ItemRotY] = 0.0;
                ItemInfo[i][ItemRotZ] = 0.0;
                Delete3DTextLabel(LabelItem[i]);
                DestroyDynamicObject(ItemObject[i]);
                AddInventoryItem(playerid,ItemInfo[i][ItemModel],ItemInfo[i][ItemAmount]);
                new string[128];format(string,sizeof(string),"~g~Pickup item ~r~ %s",GetItemName(ItemInfo[i][ItemModel],ItemInfo[i][ItemAmount]));
                ItemInfo[i][ItemAmount] = 0;
                GameTextForPlayer(playerid,string, 2000, 5);
                PlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
                return 1;
            }
        }
    }
    return 1;
}
stock RemoveInventoryItem(playerid,modelid)
{
	for(new i = 49;i>-1;i--)
	{
		if(InvInfo[playerid][iSlot][i] == modelid)
		{
			InvInfo[playerid][iSlot][i] = 0;
			InvInfo[playerid][iAmount][i] = 0;
			PlayerInfo[playerid][Slotu] -= 1;
			SetPVarInt(playerid,"MODELIDINV",0);
			SetPVarInt(playerid,"INVIAMOUNT",0);
			break;
		}
	}
	return 1;
}

stock AddInventoryItem(playerid,modelid,amount)
{
	if(PlayerInfo[playerid][Slotu] == PlayerInfo[playerid][MSlot]) return SendClientMessage(playerid,-1,"Inventory full");
	for(new i = 0;i<MAX_SLOT;i++)
	{
		if(InvInfo[playerid][iSlot][i] == 0)
		{
			InvInfo[playerid][iSlot][i] = modelid;
			InvInfo[playerid][iAmount][i] = amount;
			PlayerInfo[playerid][Slotu]+=1;
			break;
		}
	}
	return 1;
}
stock SetPlayerInventorySlot(playerid,slot)
{
	if(slot > 49 ) return SendClientMessage(playerid,-1,"Max slot is 49 ");
	PlayerInfo[playerid][MSlot] = slot;
	SetBagObject(playerid);
	return 1;
}
stock ShowBox(playerid)
{
    //HideBarStats(playerid);
	new itembox[21];
	for( new i = 0; i < MAX_BOXS;i++)
	{
		if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][bPosX],BoxInfo[i][bPosY],BoxInfo[i][bPosZ]))
		{
			for( new it = 0 ; it< 21; it++)
			{
				itembox[it] = BoxInfo[i][bItem][it];

				if(BoxInfo[i][bItem][it] == 0)
				{
				    itembox[it] = 332;
				}
			}
			//ShowModelSelectionMenuEx(playerid, itembox,20,"BOX",BOX_MENU, 0.0, 0.0,0.0,1.0,0x000000FF);
			ShowModelSelectionMenuEx(playerid, itembox,21,"BOX",BOX_MENU, 0.0, 0.0,0.0,1.0,0x000000FF);
		}
	}
	return 1;
}
stock RemoveBoxItem(boxid,modelid)
{
	for(new i = 20;i>-1;i--)
	{
		if(BoxInfo[boxid][bItem][i] == modelid)
		{
			BoxInfo[boxid][bItem][i] = 0;
			BoxInfo[boxid][bAmount][i] = 0;
			break;
		}
	}
	return SaveBoxs();
}
stock AddBoxItem(boxid,modelid,amount)
{
	for(new i = 0;i<21;i++)
	{
		if(BoxInfo[boxid][bItem][i] == 0)
		{
			BoxInfo[boxid][bItem][i] = modelid;
			BoxInfo[boxid][bAmount][i] = amount;
			break;
		}
	}
	return SaveBoxs();
}
stock ShowPutItemBoxCar(playerid)
{
    //HideBarStats(playerid);
	new iteminv[100],string[128];
	for(new i = 0; i < MAX_SLOT;i++)
	{
		iteminv[i] = InvInfo[playerid][iSlot][i];

		if(InvInfo[playerid][iSlot][i] == 0)
		{
			iteminv[i] = 332;
		}
	}
	format(string,sizeof(string),"Inventory:%d/%d(PUTBOXCAR)",PlayerInfo[playerid][Slotu],PlayerInfo[playerid][MSlot]);
	ShowModelSelectionMenuEx(playerid, iteminv,PlayerInfo[playerid][MSlot],string,PUTCARBOX_MENU, 0.0, 0.0,0.0,1.0,0x000000FF);
	return 1;
}
stock ShowPutItemBox(playerid)
{
    //HideBarStats(playerid);
	new iteminv[100],string[128];
	for(new i = 0; i < MAX_SLOT;i++)
	{
		iteminv[i] = InvInfo[playerid][iSlot][i];

		if(InvInfo[playerid][iSlot][i] == 0)
		{
			iteminv[i] = 332;
		}
	}
	format(string,sizeof(string),"Inventory:%d/%d(PUTBOX)",PlayerInfo[playerid][Slotu],PlayerInfo[playerid][MSlot]);
	ShowModelSelectionMenuEx(playerid, iteminv,PlayerInfo[playerid][MSlot],string,PUTBOX_MENU, 0.0, 0.0,0.0,1.0,0x000000FF);
	return 1;
}
stock ShowInventory(playerid)
{
    //HideBarStats(playerid);
	new iteminv[100],string[128];
	for(new i = 0; i < MAX_SLOT;i++)
	{
		iteminv[i] = InvInfo[playerid][iSlot][i];

		if(InvInfo[playerid][iSlot][i] == 0)
		{
			iteminv[i] = 332;
		}
	}
	format(string,sizeof(string),"Inventory:%d/%d",PlayerInfo[playerid][Slotu],PlayerInfo[playerid][MSlot]);
	ShowModelSelectionMenuEx(playerid, iteminv,PlayerInfo[playerid][MSlot],string,INVENTORY_MENU, 0.0, 0.0,0.0,1.0,0x000000FF);
	PlayerTextDrawShow(playerid,TextPutW);
	//new gunname[32];
    //GetWeaponNameEx(GetPlayerWeapon(playerid),gunname,sizeof(gunname));
    //GetWeaponName_New(GetPlayerWeapon(playerid),gunname);
	//format(string, sizeof(string), "Weapon:%s",gunname);
	PlayerTextDrawSetString(playerid,TextPutInvWN,string);
	//PlayerTextDrawShow(playerid,TextPutInvWN);
	return 1;
}
stock ResetInventory(playerid)
{
	for(new i = 0 ; i <= MAX_SLOT;i++){
	PlayerInfo[playerid][Slotu] = 0;
	PlayerInfo[playerid][MSlot] = 0;
	InvInfo[playerid][iSlot][i] = 0;
	}
	return 1;
}
stock SaveInventory(playerid)
{
	new file[64],string[128];
	format(file, sizeof(file), "Warz/Inventory/%s.inv", GetName(playerid));
	if(!fexist(file))
	{
	file_Create(file);
	}
	file_Open(file);
	for(new i = 0 ; i <MAX_SLOT ; i ++)
	{
	format(string,sizeof(string),"Slot%d",i);
	file_SetVal(string, InvInfo[playerid][iSlot][i]);
	format(string,sizeof(string),"Amount%d",i);
	file_SetVal(string, InvInfo[playerid][iAmount][i]);
	}
	file_Save(file);
	file_Close();
	return 1;
}

stock LoadInventory(playerid)
{
    new file[64],string[128];
	format(file, sizeof(file), "Warz/Inventory/%s.inv", GetName(playerid));
	if(!fexist(file)) return 1;
	file_Open(file);
	for(new i = 0 ; i < MAX_SLOT ; i ++)
	{
	format(string,sizeof(string),"Slot%d",i);
	InvInfo[playerid][iSlot][i] = file_GetVal(string);
    format(string,sizeof(string),"Amount%d",i);
	InvInfo[playerid][iAmount][i] = file_GetVal(string);
	}
	file_Close();
	return 1;
}
stock GetName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}

stock GetItemName(modelid,amount)
{
    new modelname[128];

    
    switch(modelid)
    {
        case 1..299:format(modelname, sizeof(modelname), "Cloth ID%d",amount);
        case 330..372: 
		{
	        new weaponid = GetModelWeapon(modelid);
		    new gunname[32];
			GetWeaponNameEx(weaponid,gunname,sizeof(gunname));
			if(weaponid == 15)
			{
			format(modelname, sizeof(modelname), "Hatchet",gunname);
			}
			else
			{
			format(modelname, sizeof(modelname), "%s",gunname);
			}
		}
		case I_Cloth: format(modelname, sizeof(modelname),"Cloth ID:%d",amount);
		case I_Lighter:format(modelname, sizeof(modelname), "Lighter");
		case I_Ladder:format(modelname, sizeof(modelname), "Ladder");
		case I_Keypad:format(modelname, sizeof(modelname), "Keypad");
		case I_Hammer:format(modelname, sizeof(modelname), "Hammer");
		case I_Gate:format(modelname, sizeof(modelname), "Metal Gate");
		case I_Metal:format(modelname, sizeof(modelname), "Metal Panel");
		case I_ToolBox:format(modelname, sizeof(modelname), "ToolBox");
		case I_Bag: format(modelname, sizeof(modelname),"Backpack Slot:%d",amount);
		case I_Medkit: format(modelname, sizeof(modelname), "Medkit");
		case I_Bandage: format(modelname, sizeof(modelname), "Bandage");
		case I_Pills: format(modelname, sizeof(modelname), "Pills");
		case I_AntiVirus: format(modelname, sizeof(modelname), "Vitamin");
        case I_Engine: format(modelname, sizeof(modelname), "Engine");
        case I_Wheel: format(modelname, sizeof(modelname), "Wheel");
        case I_Tankpart: format(modelname, sizeof(modelname), "TankPart(F1)");
        case I_Pizza: format(modelname, sizeof(modelname), "Pizza");
        case I_Wood: format(modelname, sizeof(modelname), "Wood");
        case ITEMBOX: format(modelname, sizeof(modelname), "PackBox");
        case I_Taco: format(modelname, sizeof(modelname), "Taco");
        case I_Burger: format(modelname, sizeof(modelname), "Burger");
        case I_Hotdog: format(modelname, sizeof(modelname), "HotDog");
        case I_Pesi: format(modelname, sizeof(modelname), "Pesi Can");
        case I_SodaCan: format(modelname, sizeof(modelname), "Soda Can");
        case I_NuocCam: format(modelname, sizeof(modelname), "OrangeJust");
		case I_AmmoSlot2: format(modelname, sizeof(modelname), "PistolAmmo:%d",amount);
		case I_AmmoSlot3: format(modelname, sizeof(modelname), "BuckShot Ammo:%d",amount);
		case I_AmmoSlot4: format(modelname, sizeof(modelname), "SMG Ammo:%d",amount);
		case I_AmmoSlot5: format(modelname, sizeof(modelname), "Assault Ammo:%d",amount);
		case I_AmmoSlot6: format(modelname, sizeof(modelname), "Rifle Ammo:%d",amount);
		case I_AmmoSlot7: format(modelname, sizeof(modelname), "Power Ammo:%d",amount);
		case I_GasCan:
        {
	        if(amount == 1)
	        {
			format(modelname, sizeof(modelname), "Full GasCan");
			}
			else
			{
			format(modelname, sizeof(modelname), "Empty GasCan");
			}
		}
		case I_Bottle:
        {
	        if(amount == 1)
	        {
			format(modelname, sizeof(modelname), "Water Bottle");
			}
			else
			{
			format(modelname, sizeof(modelname), "Empty Water Bottle");
			}
		}
		default: format(modelname, sizeof(modelname), "[ITEM]");
    }
    return modelname;
}
stock CreateItem(Model,amount,Float:X, Float:Y, Float:Z,Float:RX,Float:RY,Float:RZ, world, interior)
{
    if(Model != 0)
    {
        for(new i = 0; i < sizeof(ItemInfo); i++)
        {
            if(ItemInfo[i][ItemPosX] == 0.0 && ItemInfo[i][ItemPosY] == 0.0 && ItemInfo[i][ItemPosZ] == 0.0)
            {
                ItemInfo[i][ItemModel] = Model;
				ItemInfo[i][ItemAmount] = amount;
                ItemInfo[i][ItemPosX] = X;
                ItemInfo[i][ItemPosY] = Y;
                ItemInfo[i][ItemPosZ] = Z;
                ItemInfo[i][ItemRotX] = RX;
                ItemInfo[i][ItemRotY] = RY;
                ItemInfo[i][ItemRotZ] = RZ;
                ItemInfo[i][ItemVWorld] = world;
                ItemInfo[i][ItemInterior] = interior;
                //LabelForItem(i,X,Y,Z,world,interior);
               	/*if(Model > 330 && Model < 372)
               	{
                new weaponid = GetModelWeapon(Model);
                new gunname[32];
    			GetWeaponNameEx(weaponid,gunname,sizeof(gunname));
                new string[128];format(string,sizeof(string),"%s",gunname);
                LabelItem[i] = Create3DTextLabel(string,0xAFAFAFAA,X,Y,Z,5.0,world,interior);
                }*/
               	LabelItem[i] = Create3DTextLabel(GetItemName(Model,amount),0xAFAFAFAA,X,Y,Z,5.0,world,interior);
                ItemObject[i] = CreateDynamicObject(Model, X, Y, Z,RX,RY,RZ, world);
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
stock CreateBox(playerid)
{
	for(new iIndex= 0 ; iIndex< MAX_BOXS;iIndex++)
	{
		if(BoxInfo[iIndex][bCreate] == 0)
		{
			GetPlayerPos(playerid,BoxInfo[iIndex][bPosX],BoxInfo[iIndex][bPosY],BoxInfo[iIndex][bPosZ]);
			BoxInfo[iIndex][bObject] = CreateDynamicObject(964,BoxInfo[iIndex][bPosX],BoxInfo[iIndex][bPosY],BoxInfo[iIndex][bPosZ]-1,0,0,0,0,0);
			BoxInfo[iIndex][bCreate] = 1;
			for(new i = 0; i < 21;i ++)
			{
			BoxInfo[iIndex][bItem][i] = 0;
			BoxInfo[iIndex][bAmount][i] = 0;
			}
			break;
		}
	}
	return SaveBoxs();
}
stock CreateLootSpawn(type,Float:x,Float:y,Float:z)
{
	if(type == 1)
	{
	CreateItem(ItemType1[random(8)],1,x,y,z,0,0,0,0,0);
	}
	if(type == 2)
	{
	CreateItem(ItemType2[random(9)],1,x,y,z,0,0,0,0,0);
	}
	if(type == 3)
	{
	CreateItem(ItemType3[random(6)],random(20)+1,x,y,z,0,0,0,0,0);
	}
	if(type == 4)
	{
	CreateItem(ItemType4[random(4)],1,x,y,z,0,0,0,0,0);
	}
	if(type == 5)
	{
	CreateItem(I_Cloth,minrand(1,299),x,y,z,0,0,0,0,0);
	}
	if(type == 6)
	{
	CreateItem(I_Bag,minrand(1,49),x,y,z, 272.63983, 56.52002, 52.32000,0,0);
	}
	if(type == 7)//weapon
	{
	CreateItem(GetWeaponModel(minrand(1,34)),minrand(1,9),x,y,z,0,0,0,0,0);
	}
	if(type == 8)
	{
	CreateItem(ItemType8[random(2)],1,x,y,z,0,0,0,0,0);
	}
	return 1;
}
stock minrand(min, max) //By Alex "Y_Less" Cole
{
    return random(max - min) + min;
}
stock CreatePointLoot(playerid,type)
{
	for(new iIndex= 0 ; iIndex< MAX_LOOTS_SPAWN;iIndex++)
	{
		if(LootInfo[iIndex][lCreate] == 0)
		{
		GetPlayerPos(playerid,LootInfo[iIndex][lPosX],LootInfo[iIndex][lPosY],LootInfo[iIndex][lPosZ]);
		LootInfo[iIndex][lPosZ] -= 0.8;
		LootInfo[iIndex][lCreate] = 1;
		LootInfo[iIndex][lType] = type;
		CreateLootSpawn(type,LootInfo[iIndex][lPosX],LootInfo[iIndex][lPosY],LootInfo[iIndex][lPosZ]);
		break;
		}
	}
	return SavePointLoot();
}
stock DeleteBox(iIndex)
{
		if(BoxInfo[iIndex][bPosX] != 0.0 && BoxInfo[iIndex][bPosZ] != 0.0 && BoxInfo[iIndex][bPosZ] != 0.0)
		{
		    DestroyDynamicObject(BoxInfo[iIndex][bObject]);
			BoxInfo[iIndex][bPosX] = 0.0;
			BoxInfo[iIndex][bPosY] = 0.0;
			BoxInfo[iIndex][bPosZ] = 0.0;
			BoxInfo[iIndex][bCreate] = 0;
			for(new i = 0; i < 21;i ++)
			{
			BoxInfo[iIndex][bItem][i] = 0;
			BoxInfo[iIndex][bAmount][i] = 0;
			}
		}
		return SaveBoxs();
}
stock SavePointLoot()
{
	new szFileStr[1024],
	File: fHandle = fopen("Warz/Loots.cfg", io_write);

	for(new iIndex; iIndex < MAX_LOOTS_SPAWN; iIndex++)
	{
	format(szFileStr, sizeof(szFileStr), "%d|%d|%f|%f|%f|\r\n",
	LootInfo[iIndex][lCreate],
	LootInfo[iIndex][lType],
	LootInfo[iIndex][lPosX],
	LootInfo[iIndex][lPosY],
	LootInfo[iIndex][lPosZ]);
	fwrite(fHandle, szFileStr);
	}
	return fclose(fHandle);
}
stock LoadPointLoot()
{
	if(!fexist("Warz/Loots.cfg")) return 1;

	new szFileStr[128],
	File: iFileHandle = fopen("Warz/Loots.cfg", io_read),
	iIndex;

	while(iIndex < sizeof(LootInfo) && fread(iFileHandle, szFileStr))
	{
		sscanf(szFileStr, "p<|>iifff",
		LootInfo[iIndex][lCreate],
		LootInfo[iIndex][lType],
		LootInfo[iIndex][lPosX],
		LootInfo[iIndex][lPosY],
		LootInfo[iIndex][lPosZ]);
		if(LootInfo[iIndex][lCreate] == 1)
		{
	        CreateLootSpawn(LootInfo[iIndex][lType],LootInfo[iIndex][lPosX],LootInfo[iIndex][lPosY],LootInfo[iIndex][lPosZ]);
		}
		++iIndex;
	}
	return fclose(iFileHandle);
}
stock SaveBoxs()
{
	new szFileStr[1024],
	File: fHandle = fopen("Warz/Boxs.cfg", io_write);

	for(new iIndex; iIndex < MAX_BOXS; iIndex++)
	{
		format(szFileStr, sizeof(szFileStr), "%d|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|\r\n",
		BoxInfo[iIndex][bCreate],
		BoxInfo[iIndex][bPosX],
		BoxInfo[iIndex][bPosY],
		BoxInfo[iIndex][bPosZ],
		BoxInfo[iIndex][bItem][0],
		BoxInfo[iIndex][bItem][1],
		BoxInfo[iIndex][bItem][2],
		BoxInfo[iIndex][bItem][3],
		BoxInfo[iIndex][bItem][4],
		BoxInfo[iIndex][bItem][5],
		BoxInfo[iIndex][bItem][6],
		BoxInfo[iIndex][bItem][7],
		BoxInfo[iIndex][bItem][8],
		BoxInfo[iIndex][bItem][9],
		BoxInfo[iIndex][bItem][10],
		BoxInfo[iIndex][bItem][11],
		BoxInfo[iIndex][bItem][12],
		BoxInfo[iIndex][bItem][13],
		BoxInfo[iIndex][bItem][14],
		BoxInfo[iIndex][bItem][15],
		BoxInfo[iIndex][bItem][16],
		BoxInfo[iIndex][bItem][17],
		BoxInfo[iIndex][bItem][18],
		BoxInfo[iIndex][bItem][19],
		BoxInfo[iIndex][bItem][20],
		BoxInfo[iIndex][bAmount][0],
		BoxInfo[iIndex][bAmount][1],
		BoxInfo[iIndex][bAmount][2],
		BoxInfo[iIndex][bAmount][3],
		BoxInfo[iIndex][bAmount][4],
		BoxInfo[iIndex][bAmount][5],
		BoxInfo[iIndex][bAmount][6],
		BoxInfo[iIndex][bAmount][7],
		BoxInfo[iIndex][bAmount][8],
		BoxInfo[iIndex][bAmount][9],
		BoxInfo[iIndex][bAmount][10],
		BoxInfo[iIndex][bAmount][11],
		BoxInfo[iIndex][bAmount][12],
		BoxInfo[iIndex][bAmount][13],
		BoxInfo[iIndex][bAmount][14],
		BoxInfo[iIndex][bAmount][15],
		BoxInfo[iIndex][bAmount][16],
		BoxInfo[iIndex][bAmount][17],
		BoxInfo[iIndex][bAmount][18],
		BoxInfo[iIndex][bAmount][19],
		BoxInfo[iIndex][bAmount][20]);
		fwrite(fHandle, szFileStr);
	}
	return fclose(fHandle);
}

stock LoadBoxs()
{
	if(!fexist("Warz/Boxs.cfg")) return 1;

	new szFileStr[128],
	File: iFileHandle = fopen("Warz/Boxs.cfg", io_read),
	iIndex;

	while(iIndex < sizeof(BoxInfo) && fread(iFileHandle, szFileStr))
	{
		sscanf(szFileStr, "p<|>ifffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii",
		BoxInfo[iIndex][bCreate],
		BoxInfo[iIndex][bPosX],
		BoxInfo[iIndex][bPosY],
		BoxInfo[iIndex][bPosZ],
		BoxInfo[iIndex][bItem][0],
		BoxInfo[iIndex][bItem][1],
		BoxInfo[iIndex][bItem][2],
		BoxInfo[iIndex][bItem][3],
		BoxInfo[iIndex][bItem][4],
		BoxInfo[iIndex][bItem][5],
		BoxInfo[iIndex][bItem][6],
		BoxInfo[iIndex][bItem][7],
		BoxInfo[iIndex][bItem][8],
		BoxInfo[iIndex][bItem][9],
		BoxInfo[iIndex][bItem][10],
		BoxInfo[iIndex][bItem][11],
		BoxInfo[iIndex][bItem][12],
		BoxInfo[iIndex][bItem][13],
		BoxInfo[iIndex][bItem][14],
		BoxInfo[iIndex][bItem][15],
		BoxInfo[iIndex][bItem][16],
		BoxInfo[iIndex][bItem][17],
		BoxInfo[iIndex][bItem][18],
		BoxInfo[iIndex][bItem][19],
		BoxInfo[iIndex][bItem][20],
		BoxInfo[iIndex][bAmount][0],
		BoxInfo[iIndex][bAmount][1],
		BoxInfo[iIndex][bAmount][2],
		BoxInfo[iIndex][bAmount][3],
		BoxInfo[iIndex][bAmount][4],
		BoxInfo[iIndex][bAmount][5],
		BoxInfo[iIndex][bAmount][6],
		BoxInfo[iIndex][bAmount][7],
		BoxInfo[iIndex][bAmount][8],
		BoxInfo[iIndex][bAmount][9],
		BoxInfo[iIndex][bAmount][10],
		BoxInfo[iIndex][bAmount][11],
		BoxInfo[iIndex][bAmount][12],
		BoxInfo[iIndex][bAmount][13],
		BoxInfo[iIndex][bAmount][14],
		BoxInfo[iIndex][bAmount][15],
		BoxInfo[iIndex][bAmount][16],
		BoxInfo[iIndex][bAmount][17],
		BoxInfo[iIndex][bAmount][18],
		BoxInfo[iIndex][bAmount][19],
		BoxInfo[iIndex][bAmount][20]);
		if(BoxInfo[iIndex][bCreate] == 1)
		{
        BoxInfo[iIndex][bObject] = CreateDynamicObject(964,BoxInfo[iIndex][bPosX],BoxInfo[iIndex][bPosY],BoxInfo[iIndex][bPosZ]-1,0,0,0,0,0);
		}
		++iIndex;
	}
	return fclose(iFileHandle);
}

stock SetPlayerWeapon(playerid,weaponid,ammo)
{
    switch(weaponid)
    {
	    case 2..9:
	    {
	    
		    if(PlayerInfo[playerid][Weapon1] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo1] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon1] = weaponid;
		    PlayerInfo[playerid][Ammo1] = ammo;
		    }
	    }
	    case 10..15:
	    {
		    PlayerInfo[playerid][Weapon10] = weaponid;
		    PlayerInfo[playerid][Ammo10] = weaponid;
	    }
	    case 16..18:
	    {
	    	if(PlayerInfo[playerid][Weapon8] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo8] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon8] = weaponid;
		    PlayerInfo[playerid][Ammo8] = ammo;
		    }
	    }
	    case 22..24:
	    {
	    	if(PlayerInfo[playerid][Weapon2] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo2] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon2] = weaponid;
		    PlayerInfo[playerid][Ammo2] = ammo;
		    }
	    }
	    case 25..27:
	    {
	    	if(PlayerInfo[playerid][Weapon3] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo3] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon3] = weaponid;
		    PlayerInfo[playerid][Ammo3] = ammo;
		    }
	    }
	    case 28..29:
	    {
	    	if(PlayerInfo[playerid][Weapon4] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo4] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon4] = weaponid;
		    PlayerInfo[playerid][Ammo4] = ammo;
		    }
	    }
	    case 30..31:
	    {
	    	if(PlayerInfo[playerid][Weapon5] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo5] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon5] = weaponid;
		    PlayerInfo[playerid][Ammo5] = ammo;
		    }
	    }
	    case 32:
	    {
	    	if(PlayerInfo[playerid][Weapon4] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo4] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon4] = weaponid;
		    PlayerInfo[playerid][Ammo4] = ammo;
		    }
	    }
	    case 33..34:
	    {
	    	if(PlayerInfo[playerid][Weapon6] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo6] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon6] = weaponid;
		    PlayerInfo[playerid][Ammo6] = ammo;
		    }
	    }
	    case 35..38:
	    {
	    	if(PlayerInfo[playerid][Weapon7] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo7] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon7] = weaponid;
		    PlayerInfo[playerid][Ammo7] = ammo;
		    }
	    }
	    case 41..42:
	    {
	    	if(PlayerInfo[playerid][Weapon9] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo9] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon9] = weaponid;
		    PlayerInfo[playerid][Ammo9] = ammo;
		    }
	    }
	    case 44..46:
	    {
	    	if(PlayerInfo[playerid][Weapon11] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo1] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon11] = weaponid;
		    PlayerInfo[playerid][Ammo11] = ammo;
		    }
	    }
	    case 39:
	    {
     		if(PlayerInfo[playerid][Weapon8] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo8] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon8] = weaponid;
		    PlayerInfo[playerid][Ammo8] = ammo;
		    }
	    }
	    case 40:
	    {
	    	if(PlayerInfo[playerid][Weapon12] == weaponid)
		    {
		    PlayerInfo[playerid][Ammo12] += ammo;
		    }
		    else
		    {
		    PlayerInfo[playerid][Weapon12] = weaponid;
		    PlayerInfo[playerid][Ammo12] = ammo;
		    }
	    }
    }
    GivePlayerWeapon(playerid,weaponid,ammo);
    return 1;
}
stock GetModelWeapon(weaponid)
{
    switch(weaponid)
    {
        case 331:return  1;
        case 333:return  2;
        case 334:return 3;
        case 335:return 4;
        case 336:return 5;
        case 337:return 6;
        case 338:return 7;
        case 339:return 8;
        case 341:return 9;
        case 321:return 10;
        case 322:return  11;
        case 323:return  12;
        case 324:return   13;
        case 325:return   14;
        case 326:return 15;
        case 342:return   16;
        case 343:return   17;
        case 344:return   18;
        case 346:return   22;
        case 347:return   23;
        case 348:return   24;
        case 349:return   25;
        case 350:return   26;
        case 351:return   27;
        case 352:return   28;
        case 353:return   29;
        case 355:return   30;
        case 356:return   31;
        case 372:return   32;
        case 357:return   33;
        case 358:return   34;
        case 359:return   35;
        case 360:return   36;
        case 361:return   37;
        case 362:return   38;
        case 363:return   39;
        case 364:return   40;
        case 365:return   41;
        case 366:return   42;
        case 367:return   43;
        case 368:return   44;
        case 369:return   45;
        case 371:return   46;
        default: return -1;
    }
    return 0;
}
stock GetWeaponModel(weaponid)
{
    switch(weaponid)
    {
        case 1: return 331;
        case 2: return 333;
        case 3: return 334;
        case 4: return 335;
        case 5: return 336;
        case 6: return 337;
        case 7: return 338;
        case 8: return 339;
        case 9: return 341;
        case 10: return 321;
        case 11: return 322;
        case 12: return 323;
        case 13: return 324;
        case 14: return 325;
        case 15: return 326;
        case 16: return 342;
        case 17: return 343;
        case 18: return 344;
        case 22: return 346;
        case 23: return 347;
        case 24: return 348;
        case 25: return 349;
        case 26: return 350;
        case 27: return 351;
        case 28: return 352;
        case 29: return 353;
        case 30: return 355;
        case 31: return 356;
        case 32: return 372;
        case 33: return 357;
        case 34: return 358;
        case 35: return 359;
        case 36: return 360;
        case 37: return 361;
        case 38: return 362;
        case 39: return 363;
        case 40: return 364;
        case 41: return 365;
        case 42: return 366;
        case 43: return 367;
        case 44: return 368;
        case 45: return 369;
        case 46: return 371;
        default: return -1;
    }
    return -1;
}
stock RemovePlayerWeapon( playerid, weaponid )
{
    new plyWeapons[ 12 ], plyAmmo[ 12 ];

    for( new slot = 0; slot != 12; slot ++ )
    {
        new
            weap, ammo;

        GetPlayerWeaponData( playerid, slot, weap, ammo );
        if( weap != weaponid )
        {
            GetPlayerWeaponData( playerid, slot, plyWeapons[ slot ], plyAmmo[ slot ] );
        }
    }
    ResetPlayerWeaponEx(playerid);
    for( new slot = 0; slot != 12; slot ++ )
    {
        SetPlayerWeapon( playerid, plyWeapons[ slot ], plyAmmo[slot] );
    }
}
stock ResetPlayerWeaponEx(playerid)
{
    ResetPlayerWeapons(playerid);
	PlayerInfo[playerid][Weapon1] = 0;
	PlayerInfo[playerid][Weapon2] = 0;
	PlayerInfo[playerid][Weapon3] = 0;
	PlayerInfo[playerid][Weapon4] = 0;
	PlayerInfo[playerid][Weapon5] = 0;
	PlayerInfo[playerid][Weapon6] = 0;
	PlayerInfo[playerid][Weapon7] = 0;
	PlayerInfo[playerid][Weapon8] = 0;
	PlayerInfo[playerid][Weapon9] = 0;
	PlayerInfo[playerid][Weapon10] = 0;
	PlayerInfo[playerid][Weapon11] = 0;
	PlayerInfo[playerid][Weapon12] = 0;
	PlayerInfo[playerid][Ammo1] = 0;
	PlayerInfo[playerid][Ammo2] = 0;
	PlayerInfo[playerid][Ammo3] = 0;
	PlayerInfo[playerid][Ammo4] = 0;
	PlayerInfo[playerid][Ammo5] = 0;
	PlayerInfo[playerid][Ammo6] = 0;
	PlayerInfo[playerid][Ammo7] = 0;
	PlayerInfo[playerid][Ammo8] = 0;
	PlayerInfo[playerid][Ammo9] = 0;
	PlayerInfo[playerid][Ammo10] = 0;
	PlayerInfo[playerid][Ammo11] = 0;
	PlayerInfo[playerid][Ammo12] = 0;
	
}
stock SetPlayerHP(playerid,Float:hp)
{
	SetPlayerHealth(playerid,hp);
	PlayerInfo[playerid][Blood] = hp;
	return 1;
}
stock GivePlayerHP(playerid,Float:hp)
{
	SetPlayerHealth(playerid,PlayerInfo[playerid][Blood]+hp);
	PlayerInfo[playerid][Blood] += hp;
	return 1;
}
stock SetPlayerSkinEx(playerid,skinid)
{
	PlayerInfo[playerid][Skin] = skinid;
	SetPlayerSkin(playerid,skinid);
	return 1;
}

TextInit()
{
	
	TextConnect[0] = TextDrawCreate(90.000000, 41.000000, "Month");
	TextDrawBackgroundColor(TextConnect[0], -1);
	TextDrawFont(TextConnect[0], 1);
	TextDrawLetterSize(TextConnect[0], 1.900000, 13.000000);
	TextDrawColor(TextConnect[0], -1);
	TextDrawSetOutline(TextConnect[0], 1);
	TextDrawSetProportional(TextConnect[0], 1);
	TextDrawSetSelectable(TextConnect[0], 0);

	TextConnect[1] = TextDrawCreate(237.000000, 108.000000, "Z");
	TextDrawBackgroundColor(TextConnect[1], -16776961);
	TextDrawFont(TextConnect[1], 2);
	TextDrawLetterSize(TextConnect[1], 2.299999, 15.000000);
	TextDrawColor(TextConnect[1], -16776961);
	TextDrawSetOutline(TextConnect[1], 1);
	TextDrawSetProportional(TextConnect[1], 1);
	TextDrawSetSelectable(TextConnect[1], 0);

	TextConnect[2] = TextDrawCreate(94.000000, 144.000000, "Project Month Z Survival By");
	TextDrawBackgroundColor(TextConnect[2], 255);
	TextDrawFont(TextConnect[2], 2);
	TextDrawLetterSize(TextConnect[2], 0.150000, 1.000000);
	TextDrawColor(TextConnect[2], -1);
	TextDrawSetOutline(TextConnect[2], 1);
	TextDrawSetProportional(TextConnect[2], 1);
	TextDrawSetSelectable(TextConnect[2], 0);

	TextConnect[3] = TextDrawCreate(197.000000, 145.000000, "VinPure");
	TextDrawBackgroundColor(TextConnect[3], 255);
	TextDrawFont(TextConnect[3], 0);
	TextDrawLetterSize(TextConnect[3], 0.350000, 0.799999);
	TextDrawColor(TextConnect[3], 16711935);
	TextDrawSetOutline(TextConnect[3], 1);
	TextDrawSetProportional(TextConnect[3], 1);
	TextDrawSetSelectable(TextConnect[3], 0);

	TextConnect[4] = TextDrawCreate(94.000000, 156.000000, "Version 0.1Alpha");
	TextDrawBackgroundColor(TextConnect[4], -1);
	TextDrawFont(TextConnect[4], 0);
	TextDrawLetterSize(TextConnect[4], 0.400000, 1.000000);
	TextDrawColor(TextConnect[4], 255);
	TextDrawSetOutline(TextConnect[4], 1);
	TextDrawSetProportional(TextConnect[4], 1);
	TextDrawSetSelectable(TextConnect[4], 0);

	TextConnect[5] = TextDrawCreate(95.000000, 171.000000, "CREDITS:---------------------------------------");
	TextDrawBackgroundColor(TextConnect[5], 255);
	TextDrawFont(TextConnect[5], 2);
	TextDrawLetterSize(TextConnect[5], 0.200000, 1.000000);
	TextDrawColor(TextConnect[5], -1);
	TextDrawSetOutline(TextConnect[5], 1);
	TextDrawSetProportional(TextConnect[5], 1);
	TextDrawSetSelectable(TextConnect[5], 0);

	TextConnect[6] = TextDrawCreate(95.000000, 182.000000, "Dev:VinPure");
	TextDrawBackgroundColor(TextConnect[6], 255);
	TextDrawFont(TextConnect[6], 0);
	TextDrawLetterSize(TextConnect[6], 0.330000, 0.899999);
	TextDrawColor(TextConnect[6], -16776961);
	TextDrawSetOutline(TextConnect[6], 1);
	TextDrawSetProportional(TextConnect[6], 1);
	TextDrawSetSelectable(TextConnect[6], 0);

	TextConnect[7] = TextDrawCreate(138.000000, 49.000000, "SKIN");
	TextDrawBackgroundColor(TextConnect[7], 0);
	TextDrawFont(TextConnect[7], 5);
	TextDrawLetterSize(TextConnect[7], 0.500000, 1.000000);
	TextDrawColor(TextConnect[7], -1);
	TextDrawSetOutline(TextConnect[7], 0);
	TextDrawSetProportional(TextConnect[7], 1);
	TextDrawSetShadow(TextConnect[7], 1);
	TextDrawUseBox(TextConnect[7], 1);
	TextDrawBoxColor(TextConnect[7], 0);
	TextDrawTextSize(TextConnect[7], 220.000000, 191.000000);
	TextDrawSetPreviewModel(TextConnect[7], 162);
	TextDrawSetPreviewRot(TextConnect[7], 0.000000, 95.000000, 95.000000, 2.000000);
	TextDrawSetSelectable(TextConnect[7], 0);
}
MapInit()
{
	CreateObject(14553, 12.60537, 1535.17407, 16.61298,   18.12000, -0.17999, 177.18004);
	CreateObject(14548, 12.13693, 1530.46204, 17.69862,   18.24001, 1.20000, 177.30008);
	CreateObject(745, 9.85417, 1493.30286, 10.94605,   0.00000, 0.00000, 74.70001);
	CreateObject(831, 13.87572, 1532.13477, 12.58352,   0.00000, 0.00000, 0.00000);
	CreateObject(831, 17.39052, 1528.39209, 12.58352,   0.00000, 0.00000, 0.00000);
	CreateObject(831, 28.03972, 1530.57593, 12.58352,   0.00000, 0.00000, 0.00000);
	CreateObject(16113, 38.79843, 1554.08423, 11.72614,   0.00000, 0.00000, 156.41998);
	CreateObject(16113, -7.89811, 1538.36853, 4.06924,   0.00000, 0.00000, 318.65997);
	CreateObject(16113, -1.78526, 1575.74683, 9.99427,   0.00000, 0.00000, 198.35997);
	CreateObject(3461, 8.21033, 1552.72998, 11.74154,   0.00000, 0.00000, 0.00000);
	CreateObject(3594, -2.33665, 1506.50500, 11.72891,   0.00000, 0.00000, 0.00000);
	CreateObject(3594, -17.18071, 1502.95142, 11.72891,   0.00000, 0.00000, 0.00000);
	CreateObject(3594, -7.15493, 1491.30774, 11.72891,   0.00000, 0.00000, -55.37999);
	CreateObject(3594, -15.96747, 1512.31067, 11.72891,   0.00000, 0.00000, -55.37999);
	CreateObject(3594, -9.24648, 1502.24036, 11.72891,   0.00000, 0.00000, -55.37999);
	CreateObject(4509, -7.72746, 1480.98926, 14.34024,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 0.35237, 1496.46814, 12.16249,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 8.34868, 1503.46155, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 9.19123, 1488.11060, 11.68959,   0.00000, 0.00000, 56.04000);
	CreateObject(874, 1.35942, 1480.66235, 11.68959,   0.00000, 0.00000, -11.52001);
	CreateObject(874, 12.80647, 1479.22510, 11.68959,   0.00000, 0.00000, 95.99999);
	CreateObject(874, 19.82205, 1511.93799, 11.55581,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 16.84516, 1500.02173, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 22.07113, 1487.79211, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(745, 20.67817, 1506.57556, 10.94605,   0.00000, 0.00000, 74.70001);
	CreateObject(874, 25.96816, 1502.87793, 11.68959,   0.00000, 0.00000, 74.58000);
	CreateObject(2906, 29.18220, 1519.22229, 11.78302,   0.00000, 0.00000, 0.00000);
	CreateObject(2907, 18.06667, 1518.86218, 11.73407,   0.00000, 0.00000, 0.00000);
	CreateObject(2907, 6.07511, 1515.03967, 11.74200,   0.00000, 0.00000, 0.00000);
	CreateObject(2905, 7.07777, 1512.51587, 11.74348,   0.00000, 0.00000, 0.00000);
	CreateObject(2906, 2.86176, 1511.94080, 11.74381,   0.00000, 0.00000, 0.00000);
	CreateObject(2908, 9.19152, 1513.20557, 11.74308,   0.00000, 0.00000, 0.00000);
	CreateObject(3092, 0.35088, 1510.91089, 12.38069,   56.45998, 54.12001, -86.64000);
	CreateObject(874, 33.69028, 1494.72119, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, -24.52616, 1504.07642, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, -24.02072, 1526.36121, 12.33072,   0.00000, 0.00000, 0.00000);
	CreateObject(874, -44.39106, 1518.95154, 12.33072,   0.00000, 0.00000, 0.00000);
	CreateObject(874, -30.25406, 1516.66394, 11.72959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, -35.57063, 1526.00354, 11.72959,   0.00000, 0.00000, -80.46000);
	CreateObject(874, -37.05481, 1506.61816, 11.72959,   0.00000, 0.00000, 21.47999);
	CreateObject(874, -17.12982, 1510.49634, 11.72959,   0.00000, 0.00000, -5.10001);
	CreateObject(874, -26.28631, 1494.24060, 11.72959,   0.00000, 0.00000, -5.10001);
	CreateObject(874, -14.93479, 1494.05469, 11.72959,   0.00000, 0.00000, -5.10001);
	CreateObject(874, -27.92113, 1485.94348, 11.72959,   0.00000, 0.00000, 47.27999);
	CreateObject(874, 31.30465, 1522.58533, 11.55581,   0.00000, 0.00000, -41.46000);
	CreateObject(874, 23.02611, 1522.98035, 12.07430,   0.00000, 0.00000, -41.46000);
	CreateObject(874, 31.75959, 1511.18030, 12.07430,   0.00000, 0.00000, 36.42001);
	CreateObject(874, 24.88416, 1492.14136, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(3256, 10.04886, 1553.60168, -13.22879,   0.00000, 0.00000, 0.00000);
	CreateObject(3673, 7.60463, 1562.14136, -6.00082,   0.00000, 0.00000, 0.00000);
	CreateObject(3256, 11.67141, 1561.12415, -14.12716,   0.00000, 0.00000, 0.00000);
	CreateObject(3673, -13.97413, 1532.01233, -3.63529,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 7.20477, 1520.00366, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(874, 4.90050, 1512.87183, 11.68959,   0.00000, 0.00000, 0.00000);
	CreateObject(3673, 199.75781, 1397.88281, 33.41406,   3.14159, 0.00000, 1.57080);
	CreateObject(14548, 200.26181, 1405.69849, 750.96295,   0.00000, 0.00000, 0.00000);
	CreateObject(14553, 200.26212, 1401.83459, 751.23877,   0.00000, 0.00000, 0.00000);
	CreateObject(3630, 199.09909, 1400.95044, 750.81238,   21.84001, 18.95999, 88.62000);
	CreateObject(3630, 203.75305, 1415.28137, 747.77521,   21.84001, 18.95999, 82.56001);
	CreateObject(14548, -279.33386, -1295.88037, 566.42236,   0.00000, 0.00000, 0.00000);
	CreateObject(14553, -279.36429, -1299.57007, 566.67755,   0.00000, 0.00000, 0.00000);
	/*GateTeam1 = CreateDynamicObject(2990, -302.19992, 1507.44104, 78.09698,   0.00000, 0.00000, 0.00000);
	GateTeam2 = CreateDynamicObject(2990, 521.10339, 1179.81995, 32.28159,   0.00000, 0.00000, -70.92000);
	GateTeam3 = CreateDynamicObject(2990, 1705.94641, 1607.71545, 12.59211,   0.00000, 0.00000, -105.78001);
	GateTeam4 = CreateDynamicObject(2990, -653.73901, 2065.39233, 62.81072,   0.00000, 0.00000, 80.52000);
	*/
	CreateDynamicObject(16139, -377.74527, 1485.38464, 61.78148,   356.85840, 0.00000, 15.32159);
	CreateDynamicObject(16139, -346.63715, 1487.11267, 62.92772,   356.85840, 0.00000, -48.39841);
	CreateDynamicObject(16139, -396.77615, 1484.97107, 45.13603,   356.85840, 0.00000, -68.91840);
	CreateDynamicObject(16139, -398.96805, 1481.27917, 56.24475,   356.85840, 0.00000, -68.91840);
	CreateDynamicObject(3749, -302.19812, 1506.51025, 78.85323,   0.00000, 0.00000, -0.06000);
	CreateDynamicObject(16326, -293.12784, 1543.83459, 74.44392,   0.00000, 0.00000, 133.20003);
	CreateDynamicObject(16094, 606.65906, 1224.62781, 10.56187,   0.00000, 0.00000, 31.08000);
	CreateDynamicObject(16094, 606.65906, 1224.62781, 18.11672,   0.00000, 0.00000, 31.08000);
	CreateDynamicObject(16094, 606.65906, 1224.62781, 25.96324,   0.00000, 0.00000, 31.08000);
	CreateDynamicObject(2990, 500.12424, 1218.61743, 18.05016,   0.00000, 0.00000, -56.94000);
	CreateDynamicObject(2990, 500.12424, 1218.61743, 25.52454,   0.00000, 0.00000, -56.94000);
	CreateDynamicObject(2990, 713.01355, 1231.71277, 12.25483,   0.00000, 0.00000, -59.93999);
	CreateDynamicObject(3279, 658.40112, 1295.16882, 9.88810,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3279, 680.40906, 1226.08203, 10.89875,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3279, 627.11713, 1268.07214, 10.70470,   0.00000, 0.00000, 30.90000);
	CreateDynamicObject(3279, 624.01154, 1269.60974, 27.27362,   0.00000, 0.00000, 35.04000);
	CreateDynamicObject(3279, 621.75665, 1270.25391, 45.14177,   0.00000, 0.00000, 35.04000);
	CreateDynamicObject(3279, 616.37091, 1270.08130, 61.65906,   0.00000, 0.00000, 35.04000);
	CreateDynamicObject(3461, 613.70667, 1270.86316, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 613.56549, 1270.13635, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 615.55200, 1267.27661, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 616.53033, 1267.16138, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 616.52301, 1272.83826, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 617.52942, 1272.67712, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 619.29041, 1270.26294, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3461, 619.06476, 1268.79370, 78.36727,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, 616.36963, 1270.19556, 81.03787,   0.00000, 0.00000, 34.20000);
	CreateDynamicObject(18646, 554.99988, 1330.64294, 8.34953,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18646, 615.98328, 1270.23206, 81.49242,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18647, 615.75958, 1269.94226, 80.49901,   -92.28001, -14.22000, -64.62002);
	CreateDynamicObject(18657, 616.04010, 1268.68164, 84.60133,   -42.17997, -0.83999, -19.86000);
	CreateDynamicObject(18657, 618.40088, 1270.98303, 84.60133,   -42.17997, -0.83999, 112.92000);
	CreateDynamicObject(18657, 615.18378, 1270.93213, 84.60133,   -42.17997, -0.83999, 232.80000);
	CreateDynamicObject(18656, 617.27563, 1269.98279, 83.09069,   90.89999, -6.00001, -97.92001);
	CreateDynamicObject(6959, -1457.20886, 1509.73621, 0.44498,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -1416.15540, 1509.71851, 0.44498,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -1416.64697, 1549.35388, 0.44498,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(10166, -1375.16040, 1513.24072, -5.02850,   0.00000, 0.00000, -63.90001);
	CreateDynamicObject(6959, -1456.89233, 1549.44214, 0.44498,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(10815, -1336.93982, 1637.87012, 0.33567,   0.00000, 0.00000, -91.50002);
	CreateDynamicObject(8210, -1450.94507, 1568.91113, 3.11915,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(8210, -1476.63538, 1541.83826, 3.11915,   0.00000, 0.00000, -89.57999);
	CreateDynamicObject(8210, -1476.29138, 1510.76123, 3.11915,   0.00000, 0.00000, -89.57999);
	CreateDynamicObject(8210, -1407.72937, 1527.69214, 0.39527,   0.00000, 0.00000, 92.10001);
	CreateDynamicObject(3749, -1414.91980, 1562.90332, 7.25586,   0.00000, 0.00000, -46.38000);
	CreateDynamicObject(16326, -1467.91101, 1560.08240, 0.49328,   0.00000, 0.00000, 267.11996);
	CreateDynamicObject(3594, -1469.80981, 1544.33521, 0.77531,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(13295, -1424.19531, 1528.36121, 6.94239,   0.00000, 0.00000, -89.88001);
	CreateDynamicObject(16108, -1459.18286, 1521.55481, 4.83766,   0.00000, 0.00000, -0.42000);
	CreateDynamicObject(17029, -1459.27197, 1575.94409, -6.53483,   0.00000, 0.00000, 24.12000);
	CreateDynamicObject(17029, -1484.56567, 1546.96753, -6.53483,   0.00000, 0.00000, 112.85999);
	CreateDynamicObject(17029, -1484.46301, 1500.30383, -6.53483,   0.00000, 0.00000, 112.85999);
	CreateDynamicObject(8210, -218.93924, 1516.51404, 68.32291,   0.00000, 0.00000, -151.97997);
	CreateDynamicObject(8210, -208.18117, 1553.75220, 65.20328,   0.00000, 0.00000, -61.07998);
	CreateDynamicObject(8210, -244.30276, 1593.55273, 63.50930,   0.00000, 0.00000, -34.67999);
	CreateDynamicObject(8210, -289.98532, 1625.22302, 63.50930,   0.00000, 0.00000, -34.67999);
	CreateDynamicObject(8210, -338.52332, 1651.48669, 63.50930,   0.00000, 0.00000, -22.07998);
	CreateDynamicObject(8210, -377.73230, 1640.21582, 63.50930,   0.00000, 0.00000, 43.32001);
	CreateDynamicObject(8210, -406.19788, 1594.60547, 67.14130,   0.00000, 0.00000, 72.60001);
	CreateDynamicObject(8210, -417.12228, 1540.84631, 70.95908,   0.00000, 0.00000, 84.24003);
	CreateDynamicObject(8210, -393.48370, 1505.41052, 73.39584,   0.00000, 0.00000, 162.96004);
	CreateDynamicObject(8210, -360.45303, 1502.62524, 76.72841,   0.00000, 0.00000, 178.32001);
	CreateDynamicObject(8210, -360.45303, 1502.62524, 84.08365,   0.00000, 0.00000, 178.32001);
	CreateDynamicObject(8210, -393.48370, 1505.41052, 81.04299,   0.00000, 0.00000, 162.96004);
	CreateDynamicObject(8210, -208.18117, 1553.75220, 72.46159,   0.00000, 0.00000, -61.07998);
	CreateDynamicObject(8210, -244.30276, 1593.55273, 70.07436,   0.00000, 0.00000, -34.67999);
	CreateDynamicObject(8210, -289.98532, 1625.22302, 70.08623,   0.00000, 0.00000, -34.67999);
	CreateDynamicObject(8210, -338.52332, 1651.48669, 70.11034,   0.00000, 0.00000, -22.07998);
	CreateDynamicObject(8210, -377.73230, 1640.21582, 71.63266,   0.00000, 0.00000, 43.32001);
	CreateDynamicObject(8210, -406.19788, 1594.60547, 74.33622,   0.00000, 0.00000, 72.60001);
	CreateDynamicObject(8210, -417.12228, 1540.84631, 77.97533,   0.00000, 0.00000, 84.24003);
	CreateDynamicObject(8210, -218.93924, 1516.51404, 74.46265,   0.00000, 0.00000, -151.97997);
	CreateDynamicObject(8210, -267.76996, 1504.81323, 74.46265,   0.00000, 0.00000, -180.53992);
	CreateDynamicObject(8210, -267.76996, 1504.81323, 80.78251,   0.00000, 0.00000, -180.53992);
	CreateDynamicObject(8210, -218.93924, 1516.51404, 79.06131,   0.00000, 0.00000, -151.97997);
	CreateDynamicObject(8210, -338.43665, 1503.01819, 76.72841,   0.00000, 0.00000, 185.57997);
	CreateDynamicObject(8210, -338.43665, 1503.01819, 83.97345,   0.00000, 0.00000, 185.57997);
	CreateDynamicObject(8210, -305.49963, 1505.41504, 83.97345,   0.00000, 0.00000, 180.47998);
	CreateDynamicObject(18646, -226.16803, 1394.07849, 171.40627,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18646, -225.23051, 1395.89246, 171.40881,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18646, -223.22336, 1210.59656, 18.64795,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18647, -224.11858, 1394.56616, 171.40846,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(18647, -226.24409, 1394.84961, 171.40834,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(10815, 288.97919, 1099.67517, 28.24973,   -6.54000, -4.62000, 63.66000);
	CreateDynamicObject(3749, 521.45544, 1179.99438, 35.35629,   0.00000, 0.00000, -69.96000);
	CreateDynamicObject(10815, 482.06073, 1165.96790, 27.89233,   4.62000, 6.48000, 63.66000);
	CreateDynamicObject(2990, 516.53815, 1191.92566, 33.42366,   0.00000, 0.00000, -69.12000);
	CreateDynamicObject(2990, 527.19324, 1168.75134, 33.42366,   0.00000, 0.00000, -69.72000);
	CreateDynamicObject(16108, 660.63458, 1242.31433, 14.70347,   0.00000, 0.00000, 27.60000);
	CreateDynamicObject(13295, -370.28717, 1535.79443, 80.96140,   0.00000, 0.00000, 177.41992);
	CreateDynamicObject(6959, -752.86298, 2090.43115, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -752.89996, 2130.04834, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -711.91327, 2130.08521, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -670.77039, 2130.21021, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -670.85876, 2091.37793, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -711.65692, 2091.17017, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -670.80328, 2169.91772, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -711.68762, 2169.68286, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(6959, -752.66833, 2169.35498, 59.15803,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3749, -653.81458, 2065.29688, 64.05576,   0.00000, 0.00000, 76.86001);
	CreateDynamicObject(2990, -656.44135, 2050.69678, 62.25134,   0.00000, 0.00000, 77.76001);
	CreateDynamicObject(2990, -657.08154, 2048.01123, 62.25134,   0.00000, 0.00000, 77.76001);
	CreateDynamicObject(8210, -770.27753, 2066.87744, 61.90266,   0.00000, 0.00000, -78.00000);
	CreateDynamicObject(8210, -770.27753, 2066.87744, 68.77267,   0.00000, 0.00000, -78.00000);
	CreateDynamicObject(8210, -739.91833, 2047.27856, 61.93876,   0.00000, 0.00000, 7.13999);
	CreateDynamicObject(8210, -684.64313, 2050.10010, 61.93876,   0.00000, 0.00000, -1.50001);
	CreateDynamicObject(8210, -773.40674, 2119.47534, 61.44468,   0.00000, 0.00000, -89.94000);
	CreateDynamicObject(8210, -773.19745, 2162.09961, 61.44468,   0.00000, 0.00000, -90.90002);
	CreateDynamicObject(8210, -745.44128, 2188.47852, 61.44468,   0.00000, 0.00000, -180.84001);
	CreateDynamicObject(8210, -689.98895, 2187.69556, 61.44468,   0.00000, 0.00000, -180.84001);
	CreateDynamicObject(8210, -678.40411, 2187.45752, 61.44468,   0.00000, 0.00000, -179.94005);
	CreateDynamicObject(8210, -652.19562, 2159.44800, 61.44468,   0.00000, 0.00000, -269.10001);
	CreateDynamicObject(8210, -651.69556, 2103.59497, 61.44468,   0.00000, 0.00000, -270.17996);
	CreateDynamicObject(13295, -685.47882, 2168.35034, 65.63438,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(16326, -663.78577, 2144.76563, 59.10319,   0.00000, 0.00000, 88.49998);
	CreateDynamicObject(16108, -731.29108, 2169.26538, 63.37464,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(16053, -763.51068, 2138.21875, 62.59386,   0.00000, 0.00000, 89.70000);
	CreateDynamicObject(16388, -743.86005, 2088.71484, 59.58516,   0.00000, 0.00000, 89.81998);
	CreateDynamicObject(16771, -683.23627, 2114.50122, 65.70024,   0.00000, 0.00000, 179.76001);
	CreateDynamicObject(3495, -307.70926, 1507.30823, 74.76810,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, -296.64606, 1507.37512, 74.76810,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, 523.26624, 1174.43787, 32.53892,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, 519.34302, 1185.20837, 32.53892,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, -652.58759, 2070.86597, 59.81909,   0.00000, 0.00000, 0.00000);
	CreateDynamicObject(3495, -654.60394, 2059.81104, 59.81909,   0.00000, 0.00000, 0.00000);
}
/*==============================================================================

	Tires

==============================================================================*/

stock SetCarTireState(vehicleid, tire, toggle)
{
/*	if(!IsValidVehicle(vehicleid))
		return 0;*/

	new
		panels,
		doors,
		lights,
		tires,

		backright,
		frontright,
		backleft,
		frontleft;

	GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);

	decode_tires(tires, backright, frontright, backleft, frontleft);

	switch(tire)
	{
		case CAR_BANHTRUOC_TRAI:
		{
			CarData[vehicleid][vCTire1] = toggle;
			tires = encode_tires(backright, frontright, backleft, toggle);
		}
		case CAR_BANHSAU_TRAI:
		{
			CarData[vehicleid][vCTire2] =toggle;
			tires = encode_tires(backright, frontright, toggle, frontleft);
		}
		case CAR_BANHTRUOC_PHAI:
		{
			CarData[vehicleid][vCTire3] =toggle;
			tires = encode_tires(backright, toggle, backleft, frontleft);
		}
		case CAR_BANHSAU_PHAI:
		{
			CarData[vehicleid][vCTire4] =toggle;
			tires = encode_tires(toggle, frontright, backleft, frontleft);
		}
	}

	UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);

	return 1;
}

stock GetCarTireState(vehicleid, tire)
{
/*	if(!IsValidVehicle(vehicleid))
		return 0;*/

	new
		panels,
		doors,
		lights,
		tires;

	GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);

	return tires & tire;
}
stock decode_tires(input, &backright, &frontright, &backleft, &frontleft)
{
	backright = input & 0x1;
	frontright = (input >> 1) & 0x1;
	backleft = (input >> 2) & 0x1;
	frontleft = (input >> 3) & 0x1;
}
stock encode_tires(backright, frontright, backleft, frontleft)
{
	return backright | (frontright << 1) | (backleft << 2) | (frontleft << 3);
}
public OnVehicleDeath(vehicleid, killerid)
{
	DeleteVehicle(vehicleid);
	return 1;
}
stock DeleteVehicle(iIndex)
{
	CarData[iIndex][vModel] = 0;
	CarData[iIndex][vEngine] =0;
	CarData[iIndex][vHealth] =0;
	CarData[iIndex][vFuel] = 0;
	CarData[iIndex][vPosX] = 0;
	CarData[iIndex][vPosY] = 0;
	CarData[iIndex][vPosZ] = 0;
    DestroyVehicle(iIndex);
	return SaveVehicles();
}
stock CreateVehicleEx(modelid,Float:health,engine,Float:fuel,Float:x,Float:y,Float:z,tankpart,ctire1,ctire2,ctire3,ctire4)
{
	for(new iIndex =0 ; iIndex < MAX_VEHICLES;iIndex++)
	{
		if(CarData[iIndex][vModel] == 0)
		{
			iIndex = AddStaticVehicle(modelid,x,y,z,90,0,0);
			CarData[iIndex][vModel] = modelid;
			CarData[iIndex][vEngine] = engine;
			CarData[iIndex][vTankpart] = tankpart;
			CarData[iIndex][vHealth] = health;
			CarData[iIndex][vFuel] = fuel;
			CarData[iIndex][vPosX] = x;
			CarData[iIndex][vPosY] = y;
			CarData[iIndex][vPosZ] = y;
			SetVehicleHealth(iIndex,CarData[iIndex][vHealth]);
			SetCarTireState(iIndex,CAR_BANHTRUOC_TRAI,ctire1);
			SetCarTireState(iIndex,CAR_BANHSAU_TRAI,ctire2);
			SetCarTireState(iIndex,CAR_BANHTRUOC_PHAI,ctire3);
			SetCarTireState(iIndex,CAR_BANHSAU_PHAI,ctire4);
			break;
		}
	}
	return SaveVehicles();
}
stock DeleteTree(i)
{
    	TreeInfo[i][tObject] = 0;
	    TreeInfo[i][tHealth] = 0.0;
	    TreeInfo[i][tCreate] = 0;
	    TreeInfo[i][tPosX] = 0.0;
	    TreeInfo[i][tPosY] = 0.0;
	    TreeInfo[i][tPosZ] = 0.0;
	    return SaveTrees();
}
stock CreateTree(Float:health,Float:x,Float:y,Float:z)
{
	for(new i =0; i <= MAX_TREES;i++)
	{
	    if(TreeInfo[i][tCreate] == 0)
	    {
	    TreeInfo[i][tObject] = CreateDynamicObject(657,x,y,z,0,0,0);
	    TreeInfo[i][tHealth] = health;
	    TreeInfo[i][tCreate] = 1;
	    TreeInfo[i][tPosX] = x;
	    TreeInfo[i][tPosY] = y;
	    TreeInfo[i][tPosZ] = z;
	    break;
		}
	}
	return SaveTrees();
}
stock SaveTrees()
{
	new szFileStr[1024],
	File: fHandle = fopen("Warz/Trees.cfg", io_write);

	for(new iIndex = 0; iIndex <  MAX_TREES; iIndex++)
	{
	format(szFileStr, sizeof(szFileStr), "%d|%f|%f|%f|%f|\r\n",
	TreeInfo[iIndex][tCreate],
	TreeInfo[iIndex][tHealth],
	TreeInfo[iIndex][tPosX],
	TreeInfo[iIndex][tPosY],
	TreeInfo[iIndex][tPosZ]);
	fwrite(fHandle, szFileStr);
	}
	return fclose(fHandle);
}

stock LoadTrees()
{
	if(!fexist("Warz/Trees.cfg")) return 1;

	new szFileStr[128],
	File: iFileHandle = fopen("Warz/Trees.cfg", io_read),
	iIndex = 0;
	while(iIndex < MAX_TREES && fread(iFileHandle, szFileStr))
	{
		sscanf(szFileStr, "p<|>iffff",
		TreeInfo[iIndex][tCreate],
		TreeInfo[iIndex][tHealth],
		TreeInfo[iIndex][tPosX],
		TreeInfo[iIndex][tPosY],
		TreeInfo[iIndex][tPosZ]);
		TreeInfo[iIndex][tHealth] = 100.0;
		if(TreeInfo[iIndex][tCreate] == 1)
		{
	        TreeInfo[iIndex][tObject] = CreateDynamicObject(657,TreeInfo[iIndex][tPosX],TreeInfo[iIndex][tPosY],TreeInfo[iIndex][tPosZ],0,0,0);
		}
		++iIndex;
	}
	return fclose(iFileHandle);
}
stock SaveVehicles()
{
	new szFileStr[1024],
	File: fHandle = fopen("Warz/Vehicles.cfg", io_write);

	for(new iIndex = 1; iIndex < MAX_VEHICLES; iIndex++)
	{
	format(szFileStr, sizeof(szFileStr), "%d|%d|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d\r\n",
	CarData[iIndex][vModel],
	CarData[iIndex][vEngine],
	CarData[iIndex][vHealth],
	CarData[iIndex][vFuel],
	CarData[iIndex][vPosX],
	CarData[iIndex][vPosY],
	CarData[iIndex][vPosZ],
	CarData[iIndex][vTankpart],
	CarData[iIndex][vCTire1],
	CarData[iIndex][vCTire2],
	CarData[iIndex][vCTire3],
	CarData[iIndex][vCTire4]);
	fwrite(fHandle, szFileStr);
	}
	return fclose(fHandle);
}

stock LoadVehicles()
{
	if(!fexist("Warz/Vehicles.cfg")) return 1;

	new szFileStr[128],
	File: iFileHandle = fopen("Warz/Vehicles.cfg", io_read),
	iIndex = 1;

	//while(iIndex < sizeof(CarData) && fread(iFileHandle, szFileStr))
	while(iIndex < MAX_VEHICLES && fread(iFileHandle, szFileStr))
	{
		sscanf(szFileStr, "p<|>iifffffiiiii",
		CarData[iIndex][vModel],
		CarData[iIndex][vEngine],
		CarData[iIndex][vHealth],
		CarData[iIndex][vFuel],
		CarData[iIndex][vPosX],
		CarData[iIndex][vPosY],
		CarData[iIndex][vPosZ],
		CarData[iIndex][vTankpart],
		CarData[iIndex][vCTire1],
		CarData[iIndex][vCTire2],
		CarData[iIndex][vCTire3],
		CarData[iIndex][vCTire4]);
		if(CarData[iIndex][vModel] > 0)
		{
	        iIndex = AddStaticVehicle(CarData[iIndex][vModel],CarData[iIndex][vPosX],CarData[iIndex][vPosY],CarData[iIndex][vPosZ]+1,90,0,0);
	        SetVehicleHealth(iIndex,CarData[iIndex][vHealth]);
			SetCarTireState(iIndex,CAR_BANHTRUOC_TRAI,CarData[iIndex][vCTire1]);
			SetCarTireState(iIndex,CAR_BANHSAU_TRAI,CarData[iIndex][vCTire2]);
			SetCarTireState(iIndex,CAR_BANHTRUOC_PHAI,CarData[iIndex][vCTire3]);
			SetCarTireState(iIndex,CAR_BANHSAU_PHAI,CarData[iIndex][vCTire4]);
		}
		++iIndex;
	}
	return fclose(iFileHandle);
}
stock GetVehicleSpeed( vehicleid )
{
    // Function: GetVehicleSpeed( vehicleid )

    new
        Float:x,
        Float:y,
        Float:z,
        vel;

    GetVehicleVelocity( vehicleid, x, y, z );

    vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 );           // KM/H
//  vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 / MPH_KMH ); // MPH

    return vel;
}
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

stock GetBanhXe(vehicleid)
{
	new count=0;
	if(GetCarTireState(vehicleid,1) == 0)
	{
	count +=1 ;
	}
	else if(GetCarTireState(vehicleid,1) == 1)
	{
	count -=1;
	}
	if(GetCarTireState(vehicleid,2) == 0)
	{
	count +=1 ;
	}
	else if(GetCarTireState(vehicleid,2) == 1)
	{
	count -=1;
	}
	if(GetCarTireState(vehicleid,3) == 0)
	{
	count +=1 ;
	}
	else if(GetCarTireState(vehicleid,3) == 1)
	{
	count -=1;
	}
	if(GetCarTireState(vehicleid,4) == 0)
	{
	count +=1 ;
	}
	else if(GetCarTireState(vehicleid,4) == 1)
	{
	count -=1;
	}
	if(count < 0 )
	{
	count=0;
	}
	if(count > 4 )
	{
	count=4;
	}
	return count;
}
stock SetPlayerLookAt(playerid, Float:x, Float:y)
{
	new Float:Px, Float:Py, Float: Pa;
	GetPlayerPos(playerid, Px, Py, Pa);
	Pa = floatabs(atan((y-Py)/(x-Px)));
	if (x <= Px && y >= Py) Pa = floatsub(180, Pa);
	else if (x < Px && y < Py) Pa = floatadd(Pa, 180);
	else if (x >= Px && y <= Py) Pa = floatsub(360.0, Pa);
	Pa = floatsub(Pa, 90.0);
	if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
	SetPlayerFacingAngle(playerid, Pa);
}
stock GetWeaponNameEx(weaponid, weapon[], len = sizeof(weapon))
{
    switch (weaponid)
    {
        case 15:
        {
            return weapon[0] = 0, strcat(weapon, "Hatchet", len), true;
        }
        case 18:
        {
            return weapon[0] = 0, strcat(weapon, "Molotov Cocktail", len), true;
        }
        case 44:
        {
            return weapon[0] = 0, strcat(weapon, "Thermal Goggles", len), true;
        }
        case 45:
        {
            return weapon[0] = 0, strcat(weapon, "Night Vision Goggles", len), true;
        }
        default:
        {
            return GetWeaponName(weaponid, weapon, len);
        }
    }
    return false;
}
stock SetBagObject(playerid)
{
	switch(PlayerInfo[playerid][MSlot])
	{
	case 0..15:SetPlayerAttachedObject(playerid, SLOT_BAG, 3026, 1, -0.129999, -0.061999, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000, 0,0);
	case 16..30:SetPlayerAttachedObject(playerid,SLOT_BAG, 3026, 1, -0.129999, -0.061999, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.235999, 1.000000, 0,0);
	case 31..50:SetPlayerAttachedObject(playerid,SLOT_BAG, 3026, 1, -0.194000, -0.067000, 0.000000, 0.000000, 0.000000, 0.000000, 1.130000, 1.356999, 1.000000, 0,0);
	}
	return 1;
}
stock CreateFire(Float:x, Float:y, Float:z)
{
	for(new i = 0 ; i < MAX_CFS;i++)
	{
		if(CampFire[i][cCreate] == 0)
		{
		    CampFire[i][cCreate] = 1;
            CampFire[i][cPosX] = x;
            CampFire[i][cPosY] = y;
            CampFire[i][cPosZ] = z;
			CampFire[i][cObject1] = CreateDynamicObject(1463,x, y, z, 0.0, 0.0, 0.0);
			CampFire[i][cObject2] = CreateDynamicObject(18692, x, y, z-1.5, 0.0, 0.0, 0.0);
			break;
		}
	}
}
stock DeleteFire(i)
{
    CampFire[i][cCreate] = 0;
    CampFire[i][cPosX] =0.0;
    CampFire[i][cPosY] = 0.0;
    CampFire[i][cPosZ] = 0.0;
	DestroyDynamicObject(CampFire[i][cObject1]);
	DestroyDynamicObject(CampFire[i][cObject2]);
	return 1;
}
stock Log(sz_fileName[], sz_input[]) {

	new	sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
	gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
	getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
	format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
	fwrite(fileHandle, sz_logEntry);
	return fclose(fileHandle);
}
public SaveBuild(idx)
{
	new string[256];
	format(string,sizeof(string),"Warz/Build/%d.bd",idx);
	if(!fexist(string))
	{
	    file_Create(string);
	}
	file_Open(string);
	file_SetVal("Pass",BuildInfo[idx][bdPass]);
	file_SetVal("Lock",BuildInfo[idx][bdLock]);
	file_SetVal("Model",BuildInfo[idx][bdModel]);
	file_SetFloat("X",BuildInfo[idx][bdX]);
	file_SetFloat("Y",BuildInfo[idx][bdY]);
	file_SetFloat("Z",BuildInfo[idx][bdZ]);
	file_SetFloat("RX",BuildInfo[idx][bdRX]);
	file_SetFloat("RY",BuildInfo[idx][bdRY]);
	file_SetFloat("RZ",BuildInfo[idx][bdRZ]);
	file_SetVal("vID",BuildInfo[idx][bdvID]);
	file_SetVal("Int",BuildInfo[idx][bdInt]);
	file_Save(string);
	file_Close();
	return 1;
}

public LoadBuild()
{
	for(new idx=1;idx<MAX_Build;idx++)
	{
		new string[256];
        format(string,sizeof(string),"Warz/Build/%d.bd",idx);
        if(fexist(string))
        {
            file_Open(string);
            BuildInfo[idx][bdID] = idx;
            BuildInfo[idx][bdPass] = file_GetVal("Pass");
            BuildInfo[idx][bdLock] = file_GetVal("Lock");
            BuildInfo[idx][bdModel] = file_GetVal("Model");
            BuildInfo[idx][bdX] = file_GetFloat("X");
            BuildInfo[idx][bdY] = file_GetFloat("Y");
            BuildInfo[idx][bdZ] = file_GetFloat("Z");
            BuildInfo[idx][bdRX] = file_GetFloat("RX");
            BuildInfo[idx][bdRY] = file_GetFloat("RY");
            BuildInfo[idx][bdRZ] = file_GetFloat("RZ");
            BuildInfo[idx][bdvID] = file_GetVal("vID");
            BuildInfo[idx][bdInt] = file_GetVal("Int");
            CreateBuild(idx);
            file_Close();
        }
	}
	return 1;
}

public CreateBuild(ID)
{
	BuildInfo[ID][bdObject] = CreateDynamicObject(BuildInfo[ID][bdModel], BuildInfo[ID][bdX], BuildInfo[ID][bdY], BuildInfo[ID][bdZ], BuildInfo[ID][bdRX], BuildInfo[ID][bdRY], BuildInfo[ID][bdRZ], BuildInfo[ID][bdvID], BuildInfo[ID][bdInt]);
    return 1;
}
//Stock

stock GetBuildID()
{
	new i=1;
	while(i != MAX_Build) {
	    if(BuildInfo[i][bdID] == 0) {
	        return i;
		}
		i++;
	}
	return -1;
}
stock GetClosestBuildNoLock(playerid)
{
	new i=1;
	while(i != MAX_Build) {
	    if(IsPlayerInRangeOfPoint(playerid, 2, BuildInfo[i][bdX], BuildInfo[i][bdY], BuildInfo[i][bdZ])) {
	        if(BuildInfo[i][bdLock] == 0)
	        {
	        return i;
	        }
		}
		i++;
	}
	return -1;
}
stock GetClosestBuildGate(playerid)
{
	new i=1;
	while(i != MAX_Build) {
	    if(IsPlayerInRangeOfPoint(playerid, 2, BuildInfo[i][bdX], BuildInfo[i][bdY], BuildInfo[i][bdZ])) {
	    	if(BuildInfo[i][bdModel] == I_Gate)
	    	{
	        return i;
	        }
		}
		i++;
	}
	return -1;
}
stock GetClosestBuild(playerid)
{
	new i=1;
	while(i != MAX_Build) {
	    if(IsPlayerInRangeOfPoint(playerid, 2, BuildInfo[i][bdX], BuildInfo[i][bdY], BuildInfo[i][bdZ])) {
	        return i;
		}
		i++;
	}
	return -1;
}
stock GetPlayerItem(playerid,modelid)
{
	new amount;
	for(new i = 0 ; i < PlayerInfo[playerid][MSlot]; i ++)
 	{
		 if(InvInfo[playerid][iSlot][i] == modelid)
		 {
			amount = 1;
		 }
 	}
	return amount;
}
stock GetItemAmount(playerid,modelid)
{
	new amount;
	for(new i = 0 ; i < PlayerInfo[playerid][MSlot]; i ++)
 	{
		 if(InvInfo[playerid][iSlot][i] == modelid)
		 {
			amount += 1;
		 }
 	}
	return amount;
}
stock IsRangeMine(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid,8,596.8997,922.5099,-39.3426)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,588.5163,922.7329,-40.8596)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,592.0894,930.7466,-39.89644)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,596.8401,889.1705,-44.4656)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,596.1703,893.9906,-44.5620)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,606.0436,868.3897,-40.1761)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,637.4762,825.8586,-40.2286)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,546.4855,913.8973,-38.5192)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,544.9190,924.8852,-37.7166)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,550.0340,922.7172,-38.6465)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,347.4996,840.7899,20.3447)) return 1; // mine
	else if(IsPlayerInRangeOfPoint(playerid,8,356.1093,836.4151,23.5483)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,358.6918,830.9036,23.3554)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,353.5430,829.8474,24.3278)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,349.4676,823.9488,20.4303)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,360.3030,834.0552,21.6488)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,368.7826,841.5904,21.9662)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,379.3575,843.3004,24.7036)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,379.4921,857.1176,24.6892)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,372.8892,851.8807,28.0444)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,384.1935,869.5150,22.3777)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,392.2287,868.3701,22.9296)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,396.1871,877.6393,23.2880)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,385.1053,878.8181,23.5339)) return 1; // minew
	else if(IsPlayerInRangeOfPoint(playerid,8,389.9022,875.7258,24.5418)) return 1; // minew
	else return 0;
}
